akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	var taka, aoki int
	if K <= A {
		taka = A - K
		aoki = B
	} else {
		taka = 0
		aoki = B - (K - A)
	}

	fmt.Fprintln(wtr, taka, max(0, aoki))
	wtr.Flush()
}


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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, p[10], q[10], a[10], x, y, cnt = 1;
	bool valid;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		a[i] = i + 1;
	for (int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &q[i]);
	do {
		valid = true;
		for (int i = 0; i < n; i++)
			if (p[i] != a[i]) {
				valid = false;
				break;
			}
		if (valid)
			x = cnt;
		valid = true;
		for (int i = 0; i < n; i++)
			if (q[i] != a[i]) {
				valid = false;
				break;
			}
		if (valid)
			y = cnt;
		cnt++;
	} while (next_permutation(a, a + n));
	printf("%d\n", abs(x - y));
	return 0;
}

Measured memory_bytes: 256
# 解説を見た

# https://tjkendev.github.io/procon-library/python/range_query/bit.html
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


def main():
    from itertools import accumulate

    N, K = map(int, input().split())
    A = (int(input()) - K for _ in range(N))

    acc = (0,) + tuple(accumulate(A))

    def compress(iter):
        convert = {x: i for i, x in enumerate(sorted(iter), start=1)}
        # BITで扱うので、1-indexedにする
        # 値kがa番目とa+1番目に含まれているとき、k:a->k:a+1で上書きされる
        return (convert[x] for x in iter)

    comacc = tuple(compress(acc))

    ret = 0

    b = BIT(len(comacc))
    for x in comacc:
        ret += b.sum(x)
        b.add(x, 1)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37980
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  int res;
  res = max(A + B, max(A - B, A * B));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  if (s <= "2019/04/30") {
    puts("Heisei");
  }else {
    puts("TBD");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 998244353
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 4005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

char s[10];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> (s+1);

    if(s[3]==s[4] && s[6]==s[5])
        cout << "Yes\n";
    else
        cout << "No\n";



}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	N;
	std::cin >> N;
	vl	A[2];
	A[0].resize(N);
	A[1].resize(N);
	for (auto &v : A[0]) std::cin >> v;
	for (auto &v : A[1]) std::cin >> v;
	
	for (int i(N - 2); i >= 0; --i)
		A[1][i] += A[1][i+1];
	for (int i(0); i < N - 1; ++i)
		A[0][i+1] += A[0][i];
	ll	ans(0);

	for (int i(0); i < N; ++i)
		ans = std::max(ans, A[0][i] + A[1][i]);
	pnl(ans);
}



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

using namespace std;

const int mod = 998244353;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int power(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(power(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int divide(int a, int b) {
  return mul(a, power(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> ans(n + 1);
  for (int i = 1; i <= n; ++i) {
    if (n % i or (i & 1) == 0) {
      continue;
    }
    int k = n / i, res = 0;
    for (int j = 0; j < k; ++j) {
      res = add(res, res);
      if (s[j] == '1') {
        res = add(res, 1);
      }
    }
    for (int j = 0; j <= n; ++j) {
      if (j == n) {
        res = add(res, 1);
        break;
      }
      char c1 = s[j], c2;
      int p = j % (2 * k);
      if (p < k) {
        c2 = s[p];
      } else {
        c2 = '0' + '1' - s[p - k];
      }
      if (c1 == c2) {
        continue;
      } else if (c1 < c2) {
        break;
      } else {
        res = add(res, 1);
        break;
      }
    }
    ans[i] = res;
  }
  for (int i = n; i; --i) {
    for (int j = 2 * i; j <= n; j += i) {
      ans[i] = sub(ans[i], ans[j]);
    }
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    res = add(res, mul(ans[i], 2 * n / i));
  }
  cout << res;

  return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    string s;cin>>s;
    string chk="ABC";
    string c="ARC";
    if(s==c)cout<<chk;
    else cout<<c;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exist(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    string S; cin >> S;
    int K; cin >> K;
    ll dp[S.size()+1][K+1][2];
    memset(dp,0,sizeof(dp));
    dp[0][0][1] = 1;
    FOR(i,1,S.size()+1)REP(j,K+1) {
        dp[i][j][0] += dp[i-1][j][0];
        if(j) dp[i][j][0] += dp[i-1][j-1][0] * 9;
        if((int)(S[i-1]-'0')) dp[i][j][0] += dp[i-1][j][1];
        if(j && ((int)S[i-1]-'0')) dp[i][j][0] += dp[i-1][j-1][1] * ((ll)(S[i-1]-'0')-1);  
        if(S[i-1]=='0') dp[i][j][1] = dp[i-1][j][1];
        if(j && (int)(S[i-1]-'0')) dp[i][j][1] = dp[i-1][j-1][1];
    }
    cout << dp[S.size()][K][0]+dp[S.size()][K][1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = s.length();
    if(s[a - 1] == 's') cout << s << "es" << endl;
    else cout << s << 's' << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String B = "ABC";
        String R = "ARC";
        if (S.equals(B)) {
            System.out.println(R);
        } else {
            System.out.println(B);
        }
    }
}

Measured memory_bytes: 35632
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i,c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if( T[u].p == NIL) cout << "root, ";
	else if( T[u].l == NIL ) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ){
		if(i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;

}

int rec(int u, int p){
	D[u] = p;
	if( T[u].r != NIL ) rec( T[u].r, p);
	if( T[u].l != NIL ) rec( T[u].l, p + 1);

}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for( i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for( i = 0; i < n; i++){
		cin >> v >> d;
		for( j = 0; j < d; j++ ){
			cin >> c;
			if ( j == 0 ) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for ( i = 0; i < n; i++){
		if( T[i].p == NIL ) r = i;
	}

	rec(r, 0);

	for( i = 0; i < n; i++ ) print(i);

	return 0;
}

Measured memory_bytes: 5840
#include<cstdio>
#include<iostream>
#define REG register 
using namespace std;
int main(){
    
    int n;
    scanf("%d",&n);
    if ( n<1200 ) printf("ABC");
    else if ( n>=1200 && n<2800 ) printf("ARC");
    else if ( n>=2800 ) printf("AGC");
    
    return 0;
}

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

const int MAX_TIME = 120000;
const int MAX_CHANNEL = 32;
int used[MAX_CHANNEL][MAX_TIME] = {};

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

  for (int i = 0; i < n; i++) {
    int s, t, c;
    cin >> s >> t >> c;

    used[c][s - 1]++;
    used[c][t]--;

  }

  int ans = 0;
  for (int i = 1; i < MAX_TIME; i++) {
    int num = 0;
    for (int j = 0; j < MAX_CHANNEL; j++) {
      used[j][i] += used[j][i - 1];
      if (used[j][i]) num++;
    }
    ans = max(ans, num);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15232
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    int b[m];
    for (int i=0; i < m; i++) scanf("%d", &b[i]);
    int a[n][m];
    for (int i=0; i < n; i++){
        for (int j=0; j < m; j++) scanf("%d", &a[i][j]);
    }

    int res = 0;
    for (int i=0; i < n; i++){
        int sum = 0;
        for (int j=0; j < m; j++) sum += b[j] * a[i][j];
        if (-c < sum) res++;
    }

    printf("%d\n", res);

    return 0;
}



Measured memory_bytes: 128
let solve a b h m =
  let pi = 4.0 *. atan 1.0 in
  let tm = pi *. m /. 30.0 in
  let th = pi *. (h /. 6.0 +. m /. 360.0) in
  sqrt @@ a *. a +. b *. b -. 2.0 *. a *. b *. cos (tm -. th)

let () =
  Scanf.scanf "%f %f %f %f " solve |> Printf.printf "%.10f\n"


Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int n, cnt=0;
    cin >> n;
    vector<int>p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=0; i<n-2;i++){
        if((p[i+1]>p[i] && p[i+2]>p[i+1]) || (p[i+2]<p[i+1] && p[i]>p[i+1])){
            cnt++;
        }
    }
    cout << cnt;
}

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

int main(){
  string S1,S2,S3;
  cin >> S1 >> S2 >> S3;
  cout << (char)('A' + (S1.at(0) - 'a')) << (char)('A' + (S2.at(0) - 'a')) << (char)('A' + (S3.at(0) - 'a')) << endl;
}


Measured memory_bytes: 256
N = int(input())
list_x = []
list_y = []
list_distance = []

for _ in range(N):
    (x, y) = map(int, input().split())
    list_x.append(x)
    list_y.append(y)
    
for i in range(N-1):
    for j in range(i+1,N):
        xi = list_x[i]
        yi = list_y[i]    
        xj = list_x[j]
        yj = list_y[j]
        
        distance = ((xj-xi)**2 + (yj-yi)**2)**(1/2)
        list_distance.append(distance)

Total = sum(list_distance)

Ans = (2*Total)/N
print(Ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
  
int main(){
 int n;
 double a,m,sum;
 while(1){
  cin >> n;
  int s[n+1]={};
  if(n==0) break;
  
  sum=0;
  for(int i=0;i<n;++i){
   cin >> s[i];
   sum+=s[i];
  }
  m=sum/n;
  
  a=0;
  for(int i=0;i<n;++i){
   a+=pow(s[i]-m,2);
  }
  a=sqrt(a/n);
  cout << fixed << setprecision(8) << a << endl ;
 }
 return 0;
}


Measured memory_bytes: 3268
S = list(input())
N = len(S)
num = [0] * N
R = [0]
L = [N - 1]
for i in range(1, N):
  if S[i] == 'R':
    R.append(i)
  if S[i] == 'L':
    for j in R:
      num[j] = i - j
    R = []
    if S[i-1] == 'R':
      num[i] = -1
    else:
      num[i] = num[i-1] - 1

ans = [0] * N
for i, val in enumerate(num):
  temp = -(val % 2)
  if val < 0:
    temp = - temp
  ans[i + val + temp] += 1

for i in ans:
  print(i,end=" ")


Measured memory_bytes: 85612
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val A = (1..n).map { readLine()!!.split(" ").map(String::toInt) }
    val b = (1..m).map { readLine()!!.toInt() }

    (0 until n).forEach { ni ->
        println((0 until m).map { mi -> A[ni][mi] * b[mi] }.sum())
    }
}



Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,h,w;
int p[100000];
signed main(){
	int i,j,k;
	cin>>n;
	string s,t;
	cin>>s>>t;
	int ans=1;
	int le=0;
	for(i=0;i<n;i++){
		if(i<n-1&&s[i]==s[i+1]){
			if(le==0)
				ans*=6;
			else if(le==1)
				ans*=3;
			else
				ans*=2;
			i++;
			le=1;
		}
		else{
			if(le==0)
				ans*=3;
			else if(le==2)
				ans*=2;
			le=2;
		}
		ans%=mod;
	}
	cout<<ans<<endl;
}

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

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

    int s[10][10];
    vector<int> s_count(m);
    rep(i,m) {
        cin >> s_count[i];

        rep(j,s_count[i]) {
            cin >> s[i][j];
            s[i][j]--; 
        }
    }

    vector<int> p(m);
    rep(i,m) cin >> p[i];


    int ans = 0;
    rep(i,1<<n) {
        bool ok = true;
        rep(j,m) {

            int count = 0;
            rep(k,s_count[j]) {
                if (i>>s[j][k] & 1) {
                    count++;
                }
            }
            if (count % 2 != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }

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

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  char str[4];
  int i,j,c1,c2 = -1,cn1 = 0,cn2 = 0;
  gets(str,sizeof(str),stdin);
  for(i = 1, c1 = (int)str[0],cn1++;i < 4;i++){
    if(c1 == (int)str[i]){
      cn1++;
    }else{
      if(c2 == -1){
        c2 = (int)str[i];
        cn2++;
      }else if(c2 == (int)str[i]){
        cn2++;
      }else{
        break;
      }
    }
  }
  if(cn1 == cn2 && cn2 == 2){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    for s in S:
        d[s]+=1
    dd = []
    for key in d.keys():
        dd.append((-d[key],key))
    sd = sorted(dd)
    n = sd[0][0]
    for sdd in sd:
        if sdd[0] != n:
            break
        print(sdd[1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 47944
N=int(input())
ls=[[0]*9 for _ in range(9)]
for i in range(1,N+1):
  a=i
  while a//10!=0:
    a//=10
  b=i%10
  if b!=0:
    ls[a-1][b-1]+=1 
ans=0    
for i in range(1,10):
  for j in range(1,10):
    ans+=ls[i-1][j-1]*ls[j-1][i-1]
print(ans)

Measured memory_bytes: 40556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		int count = 0;
		int x = i + 1;
		while (x < K)
		{
			x *= 2;
			count++;
		}

		A[i] = count;
	}

	sort(all(A));
	int m = A[0];

	double ans = 1 / (double)N;
	ans *= pow(0.5, A[0]);

	double d = 0;
	for (int i = 0; i < N; i++)
	{
		d += pow(0.5, A[i] - A[0]);
	}
	ans *= d;

	cout << setprecision(16) << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			int[] num = new int[7];
			for(int i = 0; i < n; ++i)
			{
				int a = stdIn.nextInt();
				int b = 0;
				while(b < 6 && a >= (b + 1) * 10)
				{
					++b;
				}
				++num[b];
			}
			for(int i = 0; i < 7; ++i)
			{
				System.out.println(num[i]);
			}
		}
	}
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n, ans;

int cnt(int n) {
    int res = 0;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            res++;
            if(n / i != i) res ++;
        }
    }
    return res;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i += 2) {
        if(cnt(i) == 8) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 165 (https://atcoder.jp/contests/abc165)
// Problem: C: Many Requirements (https://atcoder.jp/contests/abc165/tasks/abc165_c)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

vector<array<int, 4>> t;

int brute(vector<int>& a, int n, int m) {
    if (sz(a) == n) {
        int sum = 0;
        trav(ti, t) {
            if (a[ti[1]-1] - a[ti[0]-1] == ti[2])
                sum += ti[3];
        }
        return sum;
    }

    int mn = sz(a) ? a.back() : 1;
    int mx = 0;
    a.push_back(0);
    reps(i, mn, m + 1) {
        a.back() = i;
        mx = max(mx, brute(a, n, m));
    }
    a.pop_back();
    return mx;
}

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

    int n, m, q; cin >> n >> m >> q;
    t.resize(q);
    for (auto& ti : t)
        cin >> ti[0] >> ti[1] >> ti[2] >> ti[3];
    vi a;
    a.reserve(10);
    cout << brute(a, n, m) << '\n';

    return 0;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  vector<int> arr(n);
  int xx = 0;
  for (int &x : arr) {
    cin >> x;
    xx ^= x;
  }
  if (n == 2) {
    swap(arr[0], arr[1]);
    for (int x : arr) {
      cout << x << ' ';
    }
    cout << endl;
    return;
  }

  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    cout << (xx ^ arr[i]) << ' ';
  }
  cout << endl;
}

signed main() {

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

  int t = 1;

#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 6332
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

bool solve(const vector<int>& a)
{
    int n = a.size();
    map<int, int> cnt;
    for(int i=0; i<n; ++i)
        ++ cnt[a[i]];

    vector<pair<int, int> > v(cnt.begin(), cnt.end());
    if(v.size() == 1){
        return v[0].first == 0;
    }
    else if(v.size() == 2){
        return
            v[0].first == 0 &&
            v[0].second * 2 == v[1].second;
    }
    if(v.size() == 3){
        return
            v[0].second == v[1].second &&
            v[1].second == v[2].second &&
            (v[0].first ^ v[1].first) == v[2].first;
    }

    return false;
}

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

    if(solve(a))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;

signed main(){
    int n, r;
    cin >> n >> r;

    if(n>=10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[,] x = new int[a, 6];
        for (int i = 0; i < a; i++)
        {
            string str1 = Console.ReadLine();
            for (int j = 0; j < 6; j++)
            {
                x[i, j] = int.Parse(str1.Split()[j]);
            }
        }
        int b = 0;
        for (int i = 0; i < a - 1; i++)
        {
            for (int j = i + 1; j < a; j++)
            {
                for (int k = 0; k < 122; k++)
                {
                    if (x[i, 0] == x[j, 0] && x[i, 5] == x[j, 5])
                    {
                        if (x[i, 1] == x[j, 1] && x[i, 4] == x[j, 4])
                        {
                            if (x[i, 2] == x[j, 2] && x[i, 3] == x[j, 3])
                            {
                                Console.WriteLine("No");
                                return;
                            }
                        }
                        else
                        {
                            b = x[j, 1]; x[j, 1] = x[j, 2]; x[j, 2] = x[j, 4];
                            x[j, 4] = x[j, 3]; x[j, 3] = b;
                        }
                    }
                    if (k % 2 == 0)
                    {
                        b = x[j, 1]; x[j, 1] = x[j, 0]; x[j, 0] = x[j, 4];
                        x[j, 4] = x[j, 5]; x[j, 5] = b;
                    }
                    else
                    {
                        b = x[j, 5]; x[j, 5] = x[j, 2]; x[j, 2] = x[j, 0];
                        x[j, 0] = x[j, 3]; x[j, 3] = b;
                    }
                }
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 5428
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int d;

vector<int> c;
vector<vector<int>> s;
vector<int> t;

int last(int d, int i) {
  int j;

  for (j=d; j>=0; j--) {
    if (t[j] == i) return d-j;
  }
  return d+1;
}

int cdiff(int, int);

int main()
{
  int i, j;

  c.resize(26);
  cin >> d;
  for(i=0; i<26; i++) {
    cin >> c[i];
  }

  s.resize(d);
  for (i=0; i<d; i++) {
    s[i].resize(26);
    for (j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  t.resize(d);

  for (i=0; i<d; i++) {
//    t[i] = i%26;
    t[i] = 0;
  }
  int conf = 0;

  for (i=0; i<d; i++) {
    conf += s[i][t[i]];
//printf("+ %d\n", s[i][t[i]]);
    for (j=0; j<26; j++) {
      int cm;
      cm = c[j] * last(i, j);
      conf -= cm;
//printf("- %d\n", cm);
    }
  }

//printf("conf = %d\n", conf);

  int maxconf, pmax;
  maxconf = conf;

  for (int loop=0; loop<50; loop++) {

    pmax = maxconf;
    for (i=0; i<d; i++) {
      int oc;
      int mc;
      oc = t[i];
      mc = oc;
//printf("t[%d] = %d conf = %d\n", i, oc, conf);
      for (j=(oc+1)%26; j!=oc; j=(j+1)%26) {
        conf += cdiff(i, j);
//printf("t[%d] = %d conf = %d\n", i, t[i], conf);
        if (conf > maxconf) {
          maxconf = conf;
          mc = j;
//printf("%d %d %d\n", i, j, conf);
        }
      }
      t[i] = mc;
      conf = maxconf;
    }
    if (maxconf == pmax) break;
    pmax = maxconf;
//printf("maxconf = %d\n", maxconf);
  }

  for (i=0; i<d; i++) {
    printf("%d\n", t[i]+1);
  }
  return 0;
}
int cdiff(int xd, int xq) {
  int rdiff;
  int oq;
  int j;

  oq = t[xd];

  rdiff = s[xd][xq] - s[xd][oq];
//printf("s[%d][%d] = %d -> s[%d][%d] = %d\n", xd ,oq, s[xd][oq], xd, xq, s[xd][xq]);

  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff += c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff += c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }

  t[xd] = xq;
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff -= c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff -= c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }
  return rdiff;
}


Measured memory_bytes: 3816
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var K = input[0].split(" ")[1]-0;
  var R = input[1].split(" ")[0]-0;
  var S = input[1].split(" ")[1]-0;
  var P = input[1].split(" ")[2]-0;
  var line = input[2].split("");
  var sum = 0;
  var ngmap = {
    r:0, s:0, p:0,
  };
  line.forEach((v,i)=>{
    if(v=="r") sum += P;
    else if(v=="s") sum += R;
    else sum += S;
    if(v==line[i-K]){
      line[i] = "x";
      ngmap[v]++;
    }
  });
  console.log(sum-ngmap.r*P-ngmap.s*R-ngmap.p*S);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


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

int main(){
	long long a,b;
	cin >> a >> b;
  	long long cnt;
  	long long ans;
  	if(a%2 == 1){
      	if(b%2 == 0){
        	cnt += (b-a-1)/2;
          	(cnt % 2 == 0?ans=a^b:ans=a^b^1);
        }else{
        	cnt += (b-a)/2;
          	(cnt % 2 == 0?ans=a:ans=a^1);
        }
    }else{
      if(b%2 == 0){
      	cnt += (b-a)/2;
        (cnt%2==0?ans=b:ans=b^1);
      }else{
      	cnt += (b-a+1)/2;
        (cnt%2==0?ans=0:ans=1);
      }
    }
	cout << ans << endl;
 
}


Measured memory_bytes: 256
program abc054b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i,j
    character(1),allocatable:: a(:,:), b(:,:)

    read*, n,m
    allocate(a(n,n),b(m,m))
    input_char : block
        character(n):: inpt_a
        character(m):: inpt_b
        do i=1,n
            read*, inpt_a
            do j=1,n
                a(j,i) = inpt_a(j:j)
            end do
        end do
        do i=1,m
            read*, inpt_b
            do j=1,m
                b(j,i) = inpt_b(j:j)
            end do
        end do
    end block input_char

    do i=1,n-m+1
        do j=1,n-m+1
            if (fit(i,j))then
                print'(a)', 'Yes'
                stop
            end if
        end do
    end do

    print'(a)', 'No'

contains
    function fit(fx,fy) result(ret)
        integer(int32):: fx,fy
        integer(int32):: x,y
        logical:: ret   
        ret = .true.
        do x=1,m
            do y=1,m
                if (b(x,y) /= a(x+fx-1,y+fy-1)) then
                    ret = .false.
                    return
                end if
            end do
        end do
    end function
end program abc054b

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a[100000];

vector<int> nxt(vector<int> x,vector<int> y){
	vector<int> res(x.size());
	for(int i=0;i<x.size();i++)
		res[i]=x[y[i]];
	return res;
}

vector<int> power(vector<int> x,long long int k){
	vector<int> res(x.size());
	for(int i=0;i<res.size();i++)
		res[i]=i;
	while(k){
		if(k&1)	res=nxt(res,x);
		x=nxt(x,x);
		k>>=1;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<int> x(n-1);
	for(int i=0;i<n-1;i++)
		x[i]=i;
	int m;
	long long int k;
	cin>>m>>k;
	for(int i=1,j;i<=m;i++){
		cin>>j;
		swap(x[j-2],x[j-1]);
	}
	x=power(x,k);
	long long int cur=a[0];
	cout<<cur<<'\n';
	for(int i=0;i<n-1;i++){
		cur+=a[x[i]+1]-a[x[i]];
		cout<<cur<<'\n';
	}
}


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

using namespace std;

using ll = long long;

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

    ll n, k;
    cin >> n >> k;

    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());
    ll sum = 0, idx = 0;
    while (idx < n) {
        sum += a[idx].second;
        if (k <= sum) break;
        ++idx;
    }

    cout << a[idx].first << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        String word = scan.next().toLowerCase();
        int sum = 0;
        String end = "END_OF_TEXT";

        //endが入力されたらbreak
        while (true) {

            String sentence = scan.next();

            if(sentence.equals(end)){

                System.out.println(sum);
                break;

            }else if(sentence.toLowerCase().equals(word)){

                sum++;

            }
        }
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int> > C(10);
    for (int i = 0; i < N; i++) {
        int c, g;
        cin >> c >> g;
        C[g-1].push_back(c);
    }


    for (auto& c : C) {
        sort(c.begin(), c.end(), greater<int>());
    }

    for (auto& c : C) {
        for (int i = 1; i < c.size(); i++) c[i] += c[i-1];
        for (int i = 1, len = c.size(); i < len; i++)
            c[i] += i * (i + 1);
        c.insert(c.begin(), 0);
    }

    vector<vector<int> > dp(1 << 10, vector<int>(K + 1, -1));
    dp[0][0] = 0;

    for (int i = 0; i < (1 << 10) - 1; i++) {
        for (int j = 0; j < 10; j++) {
            if (i & (1 << j)) continue;
            int l = 0;
            while (l <= K && dp[i][l] > -1) {
                for (int k = 0; k + l <= K && k < C[j].size(); k++) {
                    dp[i | (1 << j)][k + l] = max(dp[i | (1 << j)][l + k], dp[i][l] + C[j][k]);
                }
                l++;
            }
        }
    }

    cout << dp[(1 << 10) - 1][K] << endl;

    return 0;
}

Measured memory_bytes: 10328
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	set<string> s;
	int n; cin >> n;
	rep(i, n) {
		string x;
		cin >> x;
		s.insert(x);
	}
	cout << s.size() << endl;
	return 0;
}


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

long long lcm(long long aaa,long long bbb){
    long long g = __gcd(aaa,bbb);
    return aaa/g * bbb;
}

int main(void){
    // Your code here!
    long long int n,m,ans=-1,a,b,c;
    cin>>n>>m;
    string s;
    cin>>s;
    string t;
    cin>>t;
    if(n<m){
        a=n;
        b=m;
    }
    else {
        a=m;
        b=n;
    }    
    
ans=__gcd(n,m);
    if(ans!=-1){
        for(int j=0;j<=ans;j++){
            if(s[j*n/ans]!=t[j*m/ans]){
                ans=-1;
                break;
            }
        }
    }
else c=ans;
    if(ans!=-1){
        c=lcm(n,m);
    }
    else c=ans;
    cout<<c<<endl;
    return 0;
}


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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n;
    char str[N];
    cin>>n;
    scanf("%s",str+1);
    if(n%2){
        puts("No");
        return 0;
    }
    bool flag=1;
    for(int i=1,j=n/2+1;j<=n;i++,j++){
        if(str[i]!=str[j]){
            flag=0;
        }
    }
    puts(flag?"Yes":"No");
    return 0;
}

//Created Time  :2019/11/16 20:00:35


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace List_of_Top_3_Hills
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> h = new List<int>();

            for (int i = 0; i < 10; ++i)
            {
                h.Add(int.Parse(Console.ReadLine()));
            }

            h.Sort();

            for (int i = 9; i >= 7; --i)
            {
                Console.WriteLine(h[i]);
            }
        }
    }
}



Measured memory_bytes: 15936
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
LL ans = 0;
LL N;
int mass[10];
bool check(){
    string s;
    bool five = false;
    bool three = false;
    bool seven = false;
    for(int a = 0;a < 9;a++){
        if(mass[a] == 0){
            s.push_back('0');
        }
        if(mass[a]==1){
            s.push_back('3');
            three=true;
        }
        if(mass[a]==2){
            s.push_back('5');
            five=true;
        }
        if(mass[a]==3){
            s.push_back('7');
            seven=true;
        }
    }
    int w = stoi(s);
    s = to_string(w);
    if(count(ALL(s),'0')>=1)return false;
    //if(w<=N)cout<<w<<endl;
    return w <= N && (three&&seven&&five);
}
void calc(int i){
    if(i == 9){
        if(check())ans++;
        return;
    }
    mass[i]=0;calc(i+1);
    mass[i]=1;calc(i+1);
    mass[i]=2;calc(i+1);
    mass[i]=3;calc(i+1);
}
int main(){
    cin >> N;
    calc(0);
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

using Weight = int;

// 辺
struct Edge {
	size_t from;
	size_t to;
	Weight cost;
	Edge(size_t t, Weight c) : to(t), cost(c) {}
	Edge(size_t f, size_t t, Weight c) : from(f), to(t), cost(c) {}
	bool operator<(const Edge& rhs) const { return this->cost > rhs.cost; }
};

// グラフ G=(V,E)
struct Graph {
	size_t node;
	std::vector<std::vector<Edge>> edges;

	Graph(size_t n) : node(n), edges(n) {}
};

// 最短経路探索(非負閉路)
std::vector<int> dijkstra(const Graph& graph, const size_t s) {
	size_t n = graph.node;
	std::vector<int> used(n, -1);
	std::vector<Weight> distances(n, INF);

	distances[s] = 0;
	std::priority_queue<Edge> pq;
	pq.push(Edge(0, s, 0));
	while(!pq.empty()) {
		Edge edge = pq.top();
		pq.pop();
		if(used[edge.to] != -1) {
			continue;
		}
		used[edge.to] = edge.from;
		for(auto&& e : graph.edges[edge.to]) {
			Weight alt = edge.cost + e.cost;
			if(alt < distances[e.to]) {
				distances[e.to] = alt;
				pq.push(Edge(edge.to, e.to, alt));
			}
		}
	}
	return used;
}

int main() {
	int n, m;
	cin >> n >> m;
	VI a(m);
	VI b(m);
	Graph g(n);
	REP(i, m) {
		cin >> a[i] >> b[i];
		g.edges[a[i] - 1].push_back(Edge(a[i] - 1, b[i] - 1, 1));
		g.edges[b[i] - 1].push_back(Edge(b[i] - 1, a[i] - 1, 1));
	}
	vector<int> result = dijkstra(g, 0);
	bool is_enable = true;
	REP(i, n) {
		if(result[i] == -1) {
			is_enable = false;
			break;
		}
	}
	if(is_enable) {
		cout << "Yes" << endl;
		RANGE(i, 1, n) { cout << result[i] + 1 << endl; }
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 25316
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   ll n,m;
   cin>>n>>m;
   if(n==1 || m==1)
   {
       if(n==1 && m==1)
        cout<<"1\n";
       else
        cout<<max(n,m)-2<<"\n";
   }
   else
   {
       ll ans = (n-2)*(m-2);
       cout<<ans<<"\n";
   }



    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[][] a = new String[H + 1][W + 1];

		for (int i = 0; i < H; i++) {
			int j = 0;
			String str = sc.next();
			str = str.replace(".", "0");
			String[] s = str.split("");
			for (String x : s) {
				a[i][j] = x;
				j++;
			}
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (a[i][j].equals("#")) {
					if (i != 0) {
						if (j != 0) {
							// 1
							if (!a[i - 1][j - 1].equals("#")) {
								a[i - 1][j - 1] = String.valueOf(Integer.valueOf(a[i - 1][j - 1]) + 1);
							}
						}
						// 2
						if (!a[i - 1][j].equals("#")) {
							a[i - 1][j] = String.valueOf(Integer.valueOf(a[i - 1][j]) + 1);
						}
						if (j != (W - 1)) {
							// 3
							if (!a[i - 1][j + 1].equals("#")) {
								a[i - 1][j + 1] = String.valueOf(Integer.valueOf(a[i - 1][j + 1]) + 1);
							}
						}
					}
					if (j != 0) {
						// 4
						if (!a[i][j - 1].equals("#")) {
							a[i][j - 1] = String.valueOf(Integer.valueOf(a[i][j - 1]) + 1);
						}
					}
					if (j != (W - 1)) {
						// 5
						if (!a[i][j + 1].equals("#")) {
							a[i][j + 1] = String.valueOf(Integer.valueOf(a[i][j + 1]) + 1);
						}
					}
					if (i != (H - 1)) {
						if (j != 0) {
							// 6
							if (!a[i + 1][j - 1].equals("#")) {
								a[i + 1][j - 1] = String.valueOf(Integer.valueOf(a[i + 1][j - 1]) + 1);
							}
						}
						// 7
						if (!a[i + 1][j].equals("#")) {
							a[i + 1][j] = String.valueOf(Integer.valueOf(a[i + 1][j]) + 1);
						}
						if (j != (W - 1)) {
							// 8
							if (!a[i + 1][j + 1].equals("#")) {
								a[i + 1][j + 1] = String.valueOf(Integer.valueOf(a[i + 1][j + 1]) + 1);
							}
						}
					}
				}
			}
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				System.out.print(a[i][j]);
			}
			System.out.println("");
		}

		sc.close();
	}
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    int cnt=0;
    string b,n;

    rep(i,s.size()){
        n.push_back(s[i]);
        if(n!=b){
            cnt++;
            b=n;
            n.clear();
        }
    }
    cout<<cnt<<endl;
}


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

typedef long long int lli;

long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
typedef pair<int,int> pii;
typedef vector<int> vi;

void solve(){
  lli n;
  cin>>n;
  cout<<(n*(n-1ll)/2);
  return;
}

int main(){
  solve(); 
}

Measured memory_bytes: 256