akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=1000000007;

int n;
string s;
ll dp[3002][3002];
ll sum[3002];
int main(){
    cin>>n>>s;
    rep(i,n) dp[0][i]=1;
    rep(i,n-1){
        rep(j,n-i){
            if(s[i]=='<') {
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=mod;
            }
            else if(j>0){
                dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j-1]%=mod;
            }
        }
        if(s[i]=='<')rep(j,n){
            dp[i+1][j]+=dp[i+1][j-1];
            dp[i+1][j]%=mod;
        }
        else{
            for(int j=n-1;j>=1;--j){
                dp[i+1][j-1]+=dp[i+1][j];
                dp[i+1][j-1]%=mod;
            }
        }
    }
    cout<<dp[n-1][0]<<endl;
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll divB_C;
    ll divB_D;
    ll divB_CD;
    ll divA_C;
    ll divA_D;
    ll divA_CD;
    
    divB_C = B/C;  
    divB_D = B/D;
    divB_CD = B / lcm(C,D);
    
    divA_C = (A-1)/C;  
    divA_D = (A-1)/D;
    divA_CD = (A-1) / lcm(C,D);

    ll ans;
    // cout << divB_C << endl;
    // cout << divB_D << endl;
    // cout << divB_CD << endl;
    // cout << divA_C << endl;
    // cout << divA_D << endl;
    // cout << divA_CD << endl;

    ans = (B-A+1) - ((divB_C + divB_D - divB_CD) - (divA_C + divA_D - divA_CD));
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe";
	else cout << "safe";

	return 0;
}



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

int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 5) {
        cout << 0 << endl;
    } else if (A <= 12) {
        cout << B / 2 << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int x,y;
	cin>>x>>y;
	if(2*x <= y && y <= 4*x && y % 2 == 0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N;
  cin >> N;

  ll X[N];
  for (ll i = 0; i < N; i++) {
    cin >> X[i];
  }

  sort(X, X + N);

  ll r = LLONG_MAX;
  for (ll i = 1; i <= X[N - 1]; i++) {
    ll sum = 0;
    for (ll j = 0; j < N; j++) {
      sum += (X[j] - i) * (X[j] - i);
    }

    r = min(r, sum);
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  int A = S.size();
  int B = A + 1;
  int C = T.size();
  if(C = B)
  {
    for(int i = 0; i < A; i++)
    {
      if(S.at(i) == T.at(i))
      {
        if (i == A - 1){
        cout << "Yes" << endl;
        }
        continue;
      }
      else
      {
        cout << "No" << endl;
        break;
      }
    }
  }
  else
  {
    cout << "No" << endl;
  }
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    if(a==b) cout << c << endl;
    else if(b==c) cout << a << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N, M;
  cin >> N >> M;

  vector<vector<long>> AB(N, vector<long>(2));
  rep(i, 0, N) {
    cin >> AB[i][0] >> AB[i][1];
  }

  vector<vector<long>> CD(M, vector<long>(2));
  rep(i, 0, M) {
    cin >> CD[i][0] >> CD[i][1];
  }

  rep(i, 0, N) {
    long dist = LONG_MAX;
    long d = LONG_MAX;
    int check;
    rep(j, 0, M) {
      d = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]);
      if (dist > d) {
        check = j + 1;
        dist = d;
      }
    }
    cout << check << endl;
  }
  return 0;
}


Measured memory_bytes: 256
X=int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
  
hantei=False
while hantei==False:
  X +=1
  hantei=is_prime(X-1)
print(X-1)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;



int main() {

	int n;
	cin >> n;
	int w[101];
	int sumall = 0;

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

	int minim = 100000000;

	for (int t = 1; t < n ; t++) {
		int sumt = 0;
		for (int j = 0; j < t; j++) {
			sumt += w[j];
		}
		
		minim = min(minim, abs(2 * sumt - sumall));
	}

	cout << minim << endl;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m,c,cnt;
int b[25],a[25];
int main(){
    cin>>n>>m>>c;
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        int ans=c;
        for(int i=0;i<m;i++){
            cin>>a[i];
            ans+=a[i]*b[i];
        }
        if(ans>0)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3));
    vector<int> ans(n,0);
    rep(i,0,n)rep(j,0,3)cin>>v[i][j];

    rep(i,0,3){
        rep(j,0,n){
            bool ok=true;
            rep(k,0,n){
                if(j!=k && v[j][i]==v[k][i])ok=false;
            }
            if(ok)ans[j]+=v[j][i];

        }
    }
    rep(i,0,n){
        cout<<ans[i]<<endl;
    }
    
}


/*
abcdea

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/



Measured memory_bytes: 3132
<?php

    while(true){
        if (!choiceBankFromDataSet()) {
            break;
        }
    }
    exit;

    function choiceBankFromDataSet()
    {
        $s = trim(fgets(STDIN));
        $s = str_replace(array("\r\n","\r","\n"), '', $s);
        // ????????°
        $bankNum = (int)$s;
    
        if ($bankNum == 0) {
            return false;
        }
    
        $s = trim(fgets(STDIN));
        $s = str_replace(array("\r\n","\r","\n"), '', $s);
        $year = (int)$s;
    
        $bankInfo;
        $benefitTemp = 0;
        $benefitMax  = 0;
        $bestBankId;
        
        for ( $i = 0; $i < $bankNum; $i++) {
            $s = trim(fgets(STDIN));
            $s = str_replace(array("\r\n","\r","\n"), '', $s);
            $a = explode(" ", $s);
            $bankInfo = array('bank_id' => intval($a[0]), 'interest_rate' => intval($a[1]), 'interest_kind' => intval($a[2]));
            $benefitTemp = calcBenefit($year, $bankInfo);
            if ($benefitMax < $benefitTemp) {
                $benefitMax = $benefitTemp;
                $bestBankId = $bankInfo['bank_id'];
            }
        }
        
        echo($bestBankId . PHP_EOL);
        return true;
    }
    
    function calcBenefit($year, $bankInfo){
        $doller = 10000000;
        // ??????
        if ($bankInfo['interest_kind'] == 1) {
            $benefit = $doller * (1 + $year * $bankInfo['interest_rate'] / 100);
        } else {
            $benefit = $doller * pow((1 + $bankInfo['interest_rate'] / 100), $year);
        }
        return $benefit;
    }
?>

Measured memory_bytes: 15492
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using ll = long long;
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

constexpr ll inf = ll(1e18) + 9;

/**
 * @arg g is a digraph with possibly negative cost edges
 */
vector<ll> bellman_ford_longest_path(int root, vector<vector<pair<int, ll> > > const & g) {
    int n = g.size();
    vector<ll> dist(n, - inf);
    dist[root] = 0;
    REP (iteration, n - 1) {
        REP (i, n) for (auto edge : g[i]) {
            int j; ll cost; tie(j, cost) = edge;
            chmax(dist[j], dist[i] + cost);
        }
    }
    REP (iteration, n - 1) {
        REP (i, n) for (auto edge : g[i]) {
            int j; ll cost; tie(j, cost) = edge;
            if (dist[i] == inf or dist[j] < dist[i] + cost) {
                dist[j] = inf;
            }
        }
    }
    return dist;
}

ll solve(int n, int m, vector<vector<pair<int, ll> > > const & g) {
    return bellman_ford_longest_path(0, g)[n - 1];
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<pair<int, ll> > > g(n);
    REP (i, m) {
        int a, b, c; cin >> a >> b >> c;
        -- a; -- b;
        g[a].emplace_back(b, c);
    }
    ll answer = solve(n, m, g);
    if (answer == inf) {
        cout << "inf" << endl;
    } else {
        cout << answer << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 3656
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    b = tuple(map(int, input().split()))
    c = tuple(map(int, input().split()))
    ans = 0
    a_bef = -2

    for i in range(n):
        a_v = a[i]
        ans += b[a_v-1]
        if a_bef + 1 == a_v:
            ans += c[a_bef-1]
        a_bef = a_v
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// atcoder/abc162/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  str s;
  while (cin >> n >> s) {
    vec<int> r, g, b;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'R') r.push_back(i);
      if (s[i] == 'G') g.push_back(i);
      if (s[i] == 'B') b.push_back(i);
    }

    lli z = 0;
    const int sum = (int)'R' + (int)'G' + (int)'B';
    for (int i = 0; i < s.size(); ++i) {
      for (int j = i + 1; j < s.size(); ++j) {
        if (s[i] != s[j]) {
          const char c = sum - s[i] - s[j];
          if (c == 'R') {
            int x = r.end() - lower_bound(r.begin(), r.end(), j + 1);
            int y = binary_search(r.begin(), r.end(), j + abs(i - j));
            z += x - y;
          }
          if (c == 'G') {
            int x = g.end() - lower_bound(g.begin(), g.end(), j + 1);
            int y = binary_search(g.begin(), g.end(), j + abs(i - j));
            z += x - y;
          }
          if (c == 'B') {
            int x = b.end() - lower_bound(b.begin(), b.end(), j + 1);
            int y = binary_search(b.begin(), b.end(), j + abs(i - j));
            z += x - y;
          }
        }
      }
    }
    cout << z << endl;
  }

  return 0;
}


Measured memory_bytes: 3688
import java.util.Scanner;

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

        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] chr = new char[H+2][W+2];

        for (int i = 1; i < H+1; i++) {
            String line = sc.next();
            for (int j = 1; j < W+1; j++) {
                chr[i][j] = line.charAt(j-1);
            }
        }
        
        for (int i = 1; i < H+1; i++) {
            for (int j = 1; j < W + 1; j++) {
                if (chr[i][j] == '.') {
                    int count = 0;
                    for (int p = -1; p < 2; p++) {
                        for (int q = -1; q < 2; q++) {
                            if (chr[i + p][j + q] == '#' && !(p % 2 == 0 && q % 2 == 0)) {
                                count++;
                            }
                        }
                    }
                    System.out.print(count);
                } else {
                    System.out.print('#');
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 23764
import java.io.*;
import java.nio.IntBuffer;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami();
		int w = saori.saori_hayami();
		int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
		int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
		char[][] s = new char[h][w];
		for(int i = 0;i < h;i++){
			String str = saori.nextHayami();
			for(int j = 0;j < w;j++){
				s[i][j] = str.charAt(j);
			}
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(s[i][j] == '#'){
					System.out.print('#');
					continue;
				}
				int num = 0;
				for(int d = 0;d < 8;d++){
					int ni = i + dy[d];
					int nj = j + dx[d];
				
				if(ni < 0 || h <= ni)continue;
				if(nj < 0 || w <= nj)continue;
				if(s[ni][nj] == '#')num++;
				}
				System.out.print(num);
				s[i][j] = (char)num;
			}
			System.out.println("");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << 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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll m, k;
	cin >> m >> k;
	if(k >= pow(2,m)){
		cout << -1 << endl;
		return 0;
	} else {
		if(m == 0){
			cout << "0 0" << endl;
		} 
		else if(m == 1){
			if(k==1) cout << - 1 << endl;
			else {
				cout << "0 0 1 1" << endl;
			}
		} else {
			vector<int> ans;
			rep(i,pow(2,m)){
				if(i!=k) ans.push_back(i);
			}
			ans.push_back(k);
			rep(i,pow(2,m)){
				cout << ans[i] << " ";
			}
			REV(ans);
			For(i,1,pow(2,m)){
				cout << ans[i] << " ";
			}
			cout << k << endl;
		}
	}
}


Measured memory_bytes: 4356
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ss () = read_line () |> split_on_char ' '

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

module SeguementTree = struct

  let default_val = ref 0

  let size = ref 0

  let make n init =
    default_val := init;
    let rec pow_of_2 i =
      if i >= n then i
      else pow_of_2 (2 * i) in
    size := pow_of_2 1;
    Array.make (2 * (!size) - 1) init

  let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

  let left i = 2*i + 1

  let right i = 2*i + 2

  let update (s : int array) i x =
    let j = !size + i - 1 in
    s.(j) <- x;
    let rec doit j =
      if j <= 0 then () else
      begin
        let p = parent j in
        let l = s.(left p) in
        let r = s.(right p) in
        s.(p) <- if l < r then l else r;
        doit p
      end in
    doit j

  let find s a b =
    let rec doit a b k l r =
      if r <= a || b <= l then !default_val
      else if a <= l && r <= b then s.(k)
      else begin
        let v = doit a b (left k) l ((l + r) / 2) in
        let w = doit a b (right k) ((l + r) / 2) r in
        if v < w then v else w
      end in
    doit a b 0 0 !size

end

module S = SeguementTree

let solve n q =
  let s = S.make n 2147483647 in
  for _ = 0 to q - 1 do
    match IO.read_ns () with
    | c :: x :: y :: _ ->
      if c = 0 then S.update s x y
      else Printf.printf "%d\n" (S.find s x (y + 1))
    | _ -> assert false
  done

let () =
  match IO.read_ns () with
  | [n; q] -> solve n q
  | _ -> assert false

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

using namespace std;


void solve(int n, int a, int b, int c, vector<string>& events){
	bool possible = true;
    vector<string> res;

    for(int i = 0 ; i < (int)events.size(); i++){
    	if(events[i] == "AB"){
        	if(a == 0 and b == 0){
            	possible = false;
                break;
            }
            else if(a == 1 and b == 1 and c == 0 and i != n - 1 and events[i + 1] == "BC"){
            	a -= 1;
                b += 1;
                res.push_back("B");
            }
            else if(a == 1 and b == 1 and c == 0 and i != n - 1 and events[i + 1] == "AC"){
            	a += 1;
                b -= 1;
                res.push_back("A");
            }
           else if(a > b){
           		a -= 1;
                b += 1;
                res.push_back("B");
           }
           else{ // covers a < b and a == b and a != 1.
           		a += 1;
                b -= 1;
                res.push_back("A");
           }
        }
         else	if(events[i] == "BC"){
        	if(b == 0 and c == 0){
            	possible = false;
                break;
            }
            else if(b == 1 and c == 1 and a == 0 and i != n - 1 and events[i + 1] == "AB"){
            	c -= 1;
                b += 1;
                res.push_back("B");
            }
            else if(b == 1 and c == 1  and a == 0 and i != n - 1 and events[i + 1] == "AC"){
            	c += 1;
                b -= 1;
                res.push_back("C");
            }
           else if(b > c){
           		b -= 1;
                c += 1;
                res.push_back("C");
           }
           else{ // covers b < c and b == c and b != 1.
           		b += 1;
                c -= 1;
                res.push_back("B");
           }
        }
       else	if(events[i] == "AC"){
        	if(a == 0 and c == 0){
            	possible = false;
                break;
            }
            else if(a == 1 and c == 1 and b == 0 and i != n - 1 and events[i + 1] == "BC"){
            	a -= 1;
                c += 1;
                res.push_back("C");
            }
            else if(a == 1 and c == 1 and b == 0 and i != n - 1 and events[i + 1] == "AB"){
                a += 1;
                c -= 1;
                res.push_back("A");
            }
           else if(a > c){
           		a -= 1;
                c += 1;
                res.push_back("C");
           }
           else{ // covers a < c and a == c and a != 1.
           		a += 1;
                c -= 1;
                res.push_back("A");
           }
        }

    }

  if(possible){
  	cout << "Yes" << endl;
    for(int i = 0; i < n; i++){
    	cout << res[i] << endl;
    }
  }
  else {
  	cout << "No" << endl;
  }
}



int main(){
	int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> events(n);
   	for(int i = 0; i < n; i++){
    	cin >> events[i];
    }

    solve(n, a, b, c, events);

	return 0;
}


Measured memory_bytes: 8316
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
    let dx = [0, 1, 0, std::usize::MAX];
    let dy = [1, 0, std::usize::MAX, 0];
    input! {
        h: usize,
        w: usize,
        k: usize,
        src: (Usize1, Usize1),
        dst: (Usize1, Usize1),
        field: [Chars; h],
    }
    let mut dist = vec![vec![1i64 << 60; w]; h];
    dist[src.0][src.1] = 0;
    let mut que = std::collections::VecDeque::new();
    que.push_back(src);
    while let Some((x, y)) = que.pop_front() {
        let d = dist[x][y];
        for i in 0..4 {
            let mut cx = x;
            let mut cy = y;
            for _ in 0..k {
                let nx = cx.wrapping_add(dx[i]);
                let ny = cy.wrapping_add(dy[i]);
                if nx < h && ny < w && field[nx][ny] == '.' {
                    let nd = dist[nx][ny];
                    if nd <= d {
                        break;
                    }
                    if d + 1 < nd {
                        dist[nx][ny] = d + 1;
                        que.push_back((nx, ny));
                    }
                } else {
                    break;
                }
                cx = nx;
                cy = ny;
            }
        }
    }

    let d = dist[dst.0][dst.1];
    println!("{}", if d == (1i64 << 60) { -1 } else { d });
}


Measured memory_bytes: 16712
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(A);
	makei(B);
	say((A - 1)*(B - 1));
}

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, c;
  cin >> n >> c;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  const int V = 1000 * n + 10;
  const long long inf = (long long) 1e18;
  vector<vector<long long>> dp(n + 1, vector<long long>(V, inf));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < V; j++) {
      if (v[i - 1] <= j) {
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);    
      } else {
        dp[i][j] = dp[i - 1][j];
      }
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
    }
  }
  long long ans = 0;
  for (int j = 0; j < V; j++) {
    if (dp[n][j] <= c) {
      ans = j;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>
void printl(int *x,int n){
	for(int t=0;t<n;t++){
			printf("%d",x[t]);
			printf(t==n-1?"\n":" ");
		}
	}
int main(){
	int n,i,j,v,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	printl(a,n);
	for(i=1;i<n;i++){
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
			}
		a[j+1]=v;
		printl(a,n);
		}
	}


Measured memory_bytes: 2080
#include<cstdio>
int main()
{
    int n,a[60],cnt=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(int i=0; i<n; i++)
    {
        int flag=1;
        for(int j=0; j<i; j++)
        {
            if(a[j]>a[i])
            {
                flag=0;
                break;
            }
        }
        if(flag)
            cnt++;
    }
    printf("%d",cnt);
    return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n; cin >> n;


	vector <long double> a(n);

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

	long double den = 0;


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


	cout << fixed << setprecision(8) << 1.0 / den << endl;
	

	return 0;
}

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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	vector<pair<int,int>>v(N);
	for(auto &i:v)cin>>i.first>>i.second;
	vector<int>ans(N);
	for(int i=0;i<N;i++)ans[i]=v[i].second;
	vector<vector<int>>dp(N,vector<int>(K));
	for(int i=0;i<N-1;i++){
		for(int k=K-1;k>=v[i].first;k--)dp[i+1][k]=max(dp[i][k],dp[i][k-v[i].first]+v[i].second);
		for(int k=min((int)K-1,v[i].first-1);k>=0;k--)dp[i+1][k]=dp[i][k];
	}
	vector<vector<int>>rev_dp(N,vector<int>(K));
	for(int i=N-1;i>0;i--){
		for(int k=K-1;k>=v[i].first;k--)rev_dp[i-1][k]=max(rev_dp[i][k],rev_dp[i][k-v[i].first]+v[i].second);
		for(int k=min((int)K-1,v[i].first-1);k>=0;k--)rev_dp[i-1][k]=rev_dp[i][k];
	}
	for(int i=0;i<N;i++){
		int add=0;
		for(int j=0;j<K;j++){
			add=max(add,dp[i][j]+rev_dp[i][K-1-j]);
		}
		ans[i]+=add;
	}
	cout<<*max_element(ans.begin(),ans.end())<<endl;
}

Measured memory_bytes: 70912
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  if(s=="Rainy")cout<<"Sunny"<<endl;
  if(s=="Cloudy")cout<<"Rainy"<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,m;
    cin >> n >> m;
    ll x[n],y[n],z[n];
   
    rep(i,0,n)cin >> x[i] >> y[i] >> z[i];
    
    ll ans = 0;
    rep(i,0,8){
	ll sum[n];
	rep(j,0,n)sum[j] = (((i&1) == 0)?x[j]:-x[j]) + (((i&2) == 0)?y[j]:-y[j]) + (((i&4) == 0)?z[j]:-z[j]);
	rsort(sum,sum+n,ll);
	ll tmp = 0;
	rep(j,0,m)tmp += sum[j];
	ans = max(ans,tmp);
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
ll N,D,ans=0;
cin >> N >> D;
vector<ll> X(N) , Y(N);
REP(i,N){
    cin >> X[i] >> Y[i];
    if(sqrt(X[i]*X[i]+Y[i]*Y[i])<=D){
        ans++;
    }
}
answer(ans);
return 0;
}


Measured memory_bytes: 6424
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    X, Y = in_nn()

    ans = 'No'
    for i in range(X + 1):
        if 2 * i + 4 * (X - i) == Y:
            ans = 'Yes'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9276
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

signed main()
{
    Start();
    ld ans = 0.0;
    int n;
    cin >> n;
#define x first
#define y second
    vector <pld> a(n);
    cin >> a;
    vector <int> p(n);
    ld fact = 1;
    for (int i = 1; i <= n; ++i)
        fact *= i;
    iota(all(p), 0);
    do
    {
        ld cur = 0;
        for (int i = 1; i < n; ++i)
        {
            cur += sqrtl((a[p[i]].x - a[p[i - 1]].x) * (a[p[i]].x - a[p[i - 1]].x) + (a[p[i]].y - a[p[i - 1]].y) * (a[p[i]].y - a[p[i - 1]].y));
        }
        cur /= fact;
        ans += cur;
    } while (next_permutation(all(p)));
    cout << setprecision(12) << fixed << ans;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int x = 0 ;
 
  // ここにプログラムを追記
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') {
       x ++ ;
    }
    else if (S.at(i) == '-') {
       x -- ;
    }
  }
  cout << x << endl;
}

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

int main() {

    int io = 0;
    int oi = 0;
    string s;
    cin >> s;
    int n = s.size();
    for (int i=0; i<n; i++) {
        if (i % 2 == 0) {
            if (s[i] == '0') {
                io++;
            }
            else {
                oi++;
            }
        }
        else {
            if (s[i] == '1') {
                io++;
            }
            else {
                oi++;
            }
        }
    }
    cout << min(io, oi);

}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, k, v[55], sisa, a, b, cnt, u[55], temp, ans = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &v[i]);
	a = min(n, k);
	for (int i = 0; i <= a; i++) {
		b = a - i;
		for (int j = 0; j <= b; j++) {
			cnt = 0;
			temp = 0;
			for (int p = 0; p < i; p++) {
				temp += v[p];
				u[cnt++] = v[p];
			}
			for (int p = 0; p < j; p++) {
				temp += v[n - p - 1];
				u[cnt++] = v[n - p - 1];
			}
			sort(u, u + cnt);
			sisa = min(cnt, k - cnt);
			for (int p = 0; p < sisa; p++) {
				if (u[p] >= 0)
					break;
				temp -= u[p];
			}
			ans = max(ans, temp);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      h: [usize; n],
      ab: [(Usize1, Usize1); m]
   }
   let mut to = vec![Vec::new(); n];
   for (a, b) in ab {
      to[a].push(b);
      to[b].push(a);
   }
   let mut ans = 0;
   for v in 0..n {
      let mut flag = true;
      for u in to[v].iter().copied() {
         if h[u] >= h[v] {
            flag = false;
            break;
         }
      }
      if flag {
         ans += 1;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 12188
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = readln.chomp.split.to!(int[]);
  min(a[0]*a[1], a[2]).writeln;
}


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

using i64 = int64_t;

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

constexpr i64 MOD = 1e9 + 7;

i64 solve(string s, int d) {
    i64 dp[(int)s.size()+1][2][d];
    rep(i, s.size()+1)rep(j, 2)rep(k, d)dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i, s.size()) rep(j, 2) rep(k, d) {
        int lim = j ? 9 : s[i] - '0';
        rep(l, lim + 1) {
            dp[i + 1][j || l < lim][(k+l)%d] += dp[i][j][k];
            dp[i + 1][j || l < lim][(k+l)%d] %= MOD;
        }
    }
    i64 ans = 0;
    rep(j, 2){
        ans += dp[s.size()][j][0];
        ans %= MOD;
    }
    ans--;  // exclude zero
    if(ans < 0)ans += MOD;
    return ans;
}

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

    cout << solve(s, d) << endl;

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

const int MAX_N = 1e6;

struct UnionFind{
    int N;
    int par[MAX_N];

    UnionFind(int N): N(N){
        for (int i=0;i<N;i++){
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        int rx = root(par[x]);
        par[x] = rx;
        return rx;
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

    bool find(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	if(N<2*(N-M-1)){
		cout << "Impossible" << endl;
		return 0;
	}
	if(M==N-1){
		cout << 0 << endl;
		return 0;
	}

	UnionFind uf(N);
	ll x, y;
	REP(i, M){
		cin >> x >> y;
		uf.unite(x, y);
	}

	priority_queue<ll, vector<ll>, greater<ll> > pq[N];
	priority_queue<ll, vector<ll>, greater<ll> > pqr;
	REP(i, N){
		pq[uf.root(i)].push(a[i]);
	}

	ll res = 0;

	REP(i, N){
		if(pq[i].empty()) continue;
		res += pq[i].top();
		pq[i].pop();
		while(!pq[i].empty()){
			ll tmp = pq[i].top();
			pq[i].pop();
			pqr.push(tmp);
		}
	}
	REP(i, N-M-2){
		res += pqr.top();
		pqr.pop();
	}

	cout << res << endl;

    return 0;
}

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
int main()
{
    int a[3] = {0, 0, 0};

    cin >> a[0] >> a[1] >> a[2];

    int fn = 0;
    int sn = 0;

    for(int i = 0; i < 3; i++)
    {
        if(a[i] == 5)
        {
            fn++;
        }
        else if(a[i] == 7)
        {
            sn++;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    if(fn == 2 && sn == 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256