akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_145C(){
    int n;
    cin >> n;

    int x[n], y[n];
    REP(i,n) cin >> x[i] >> y[i];

    int array[n];
    REP(i,n) array[i] = i;

    double answer = 0;

    do{
        for(int i = 0; i < n-1; i++){
            answer += (double)sqrt(pow(x[array[i+1]] - x[array[i]], 2) + pow(y[array[i+1]] - y[array[i]], 2));
        }
    } while(next_permutation(array, array + n));

    ll div = 1;
    REP(i,n) div *= (i+1);

    printf("%.7f", (double)(answer / div));
}

int main(void){
    solve_145C();
    
    return 0;
}

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

using namespace std;

#define LEN 'z'-'a'+1
int chs[LEN], chs2[LEN];

void solve() {
    int n;
    char c;
    cin >> n;
    for (int j = 0; j < LEN; ++j)
        chs[j] = 1000000;
    c  = getchar();
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < LEN; ++j) {
            chs2[j] = 0;
        }
        while ((c = getchar()) != '\n') {
            ++chs2[c - 'a'];
        }
        for (int j = 0; j < LEN; ++j) {
            chs[j] = min(chs[j], chs2[j]);
        }
    }
    for (int i = 0; i < LEN; ++i) {
        for (int j=0; j < chs[i]; ++j)
            cout << char('a'+i);
    }
    //cout << endl;


}

int main() {

    solve();
    return 0;
}


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

int main()
{
    int dp[3];
    memset(dp,0,sizeof(dp));
    
    int n;
    cin>>n;
    
    for(int i=1;i<=n;i++){
        
        int ndp[3];
        memset(ndp,0,sizeof(ndp));
        
        int c[3];
        for(int m=0;m<3;m++)
        cin>>c[m];
        
        for(int m=0;m<3;m++){
            for(int j=0;j<3;j++){
                
                if(m != j){
                    ndp[j] = max(ndp[j],(dp[m]+c[j]));
                }
            }
        }
        for(int j=0;j<3;j++)
        dp[j] = ndp[j];
    }
    
    cout<<(max(dp[0],max(dp[1],dp[2])));
       
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B=MAP()
A-=1
# A-1での各ビットが立つ回数
A2=[0]*50
# Bでの各ビットが立つ回数
B2=[0]*50
# あるビットが奇数かどうか
odd=[0]*50
# ビット毎でループする
for i in range(1, 50):
    T=2**i
    # 循環する分を足す
    A2[i]+=A//T*(T//2)
    # 最後の部分を足す
    A2[i]+=max(A%T-(T//2-1), 0)
    B2[i]+=B//T*(T//2)
    B2[i]+=max(B%T-(T//2-1), 0)
    # A-1で立った数-Bで立った数で[A,B]の区間で立った数にする
    if (B2[i]-A2[i])%2==1:
        odd[i]=1
ans=0
for i in range(1, 50):
    if odd[i]:
        # 奇数個立っていたビットの分を足していく
        ans+=2**(i-1)
print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
ll c[N][3], f[N][3], n;
int main()
{
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    for (int j = 0; j < 3; j++)
        f[n - 1][j] = c[n - 1][j];
    for (ll i = n - 2; i >= 0; i--)
    {
        f[i][0] = c[i][0] + max(f[i + 1][1], f[i + 1][2]);
        f[i][1] = c[i][1] + max(f[i + 1][0], f[i + 1][2]);
        f[i][2] = c[i][2] + max(f[i + 1][0], f[i + 1][1]);
    }
    cout << max(f[0][0], max(f[0][1], f[0][2]));
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;

int main(){
    LL N, K;
    cin >> N >> K;
    vector<LL>  vx, vy;
    vector<P>   vp;
    for(int i = 0;i < N;i++){
        LL xi, yi;
        cin >> xi >> yi;
        vx.emplace_back(xi);
        vy.emplace_back(yi);
        vp.emplace_back(P(xi, yi));
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    LL ans = -1;
    for(int i = 0;i < N;i++){
        for(int j = i+1;j < N;j++){
            for(int k = 0;k < N;k++){
                for(int l = k+1;l < N;l++){
                    int count = 0;
                    for(int m = 0;m < N;m++){
                        LL x = vp[m].first;
                        LL y = vp[m].second;
                        if(x >= vx[i] && x <= vx[j] && y >= vy[k] && y <= vy[l])    count++;  
                    }
                    if(count >= K){
                        if(ans == -1 || ans > (vx[j]-vx[i])*(vy[l]-vy[k]))  ans = (vx[j]-vx[i])*(vy[l]-vy[k]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc100/tasks/arc100_a

N = read_a_int()
A = read_ints()
# Ai-iをBiとする
# Σ|Bi - b|を最小化するはBiの中央値(ということを経験的に知っている)(二部探索してみればいいこと)

B = []
for i, a in enu(A, start=1):
    B.append(a - i)
import numpy as np
b = np.median(B)
ans = 0
print(int(np.abs(np.array(B) - b).sum()))


Measured memory_bytes: 31356
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  if ((B-A) % 2 == 0) {
    cout << (B-A) / 2 << endl;
    return;
  } else {
    ll aaa = min(A-1, N-B);
    ll ans = aaa + 1 + (B-A) / 2;
    cout << ans << endl;
    return;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
    int n,k; cin>>n>>k;
    ll a[n];
    ll prod = 1ll;
    f(i,n){
    	cin>>a[i];
	}
	sort(a, a+n);
	if(a[n-1] == 0 && (k&1)){
		cout<<0<<endl;
		return;
	}
	if(a[n-1] <= 0 && (k&1)){
		for(int i=n-1;i>=n-k;i--){
			prod = ((prod%mod)*(a[i]%mod))%mod;
		}
		prod = (prod+mod)%mod;
		cout<<prod<<endl;
		return;
	}
	int i=0, j=n-1;
	if(k&1){
		prod = (prod*a[j])%mod;
		j--;
		k--;
	}
	k >>= 1ll;
	for(int l=0;l<k;l++){
		ll x = a[i]*a[i+1];
		ll y = a[j]*a[j-1];
		if(x > y){
			prod = ((prod%mod)*(x%mod))%mod;
			i += 2;
		}
		else{
			prod = ((prod%mod)*(y%mod))%mod;
			j -= 2;
		}
	}
	prod = (prod+mod)%mod;
	cout<<prod<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 5256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<ll> from_left(n+1, 0);
  vector<ll> from_right(n+1, 0);
  rep(i, n) {
    from_left[i+1] = from_left[i];
    if (s[i] == 'W') from_left[i+1]++;
  }
  repr(i, n-1) {
    from_right[i] = from_right[i+1];
    if (s[i] == 'E') from_right[i]++;
  }
  ll ans = INF;
  for(int i = 0; i <= n; i++) {
    ans = min(ans, from_left[i] + from_right[i]);
  }
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 8248
x = int(input())

def dec(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

for i in range(x,10**5+4):
    if len(dec(i)) == 1:
        print(i)
        exit()

print('error')

Measured memory_bytes: 39024
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

a,b = input().split()

a = int(a)
b = 100*int(b[0])+int(b[2:])
print((a*b)//100)

Measured memory_bytes: 61880
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

# 逆元配列の作成
inv = [1] * (2 * (10 ** 5)+1)
for i in range(2, 2 * (10 ** 5)+1):
    inv[i] = -inv[mod % i] * (mod // i)
    inv[i] %= mod


def comb(n, a):
    res = 1
    for i in range(a):
        res *= n - i  # 分子
        res *= inv[i + 1]  # 分母
        res %= mod  # modで割ったあまり
    return res


ans = pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)

ans %= mod
if ans < 0:
    ans += mod

print(ans)


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

ll n, k, a[1000], sum = 0, ans = 0;

int main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    sort(a+1, a+n+1);
    if (k > sum) cout << n - 1;
    else if (k < a[1]) cout << 0;
    else{
        for (int i = 1; i <= n; i++){
            if (k >= a[i]){
                ans++;
                k -= a[i];
            }
            else break;
        }
        cout << ans;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> ma;
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
        ma[A[i]]++;
    }

    int Q;
    cin >> Q;
    rep(i, Q) {
        ll b, c;
        cin >> b >> c;
        ll num = ma[b];
        sum = sum - b * num + c * num;
        cout << sum << endl;
        ma[b] = 0;
        ma[c] += num;
    }
}

Measured memory_bytes: 9944
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int num[100005];
//0..w 1...h
int main()
{
	srand((unsigned int)time(NULL));
	while(1)
	{
		vector<int>vec[2];
		int n; scanf("%d",&n); if(!n) return 0;
		num[0]=-1;
		for(int i=1;i<=n;i++) scanf("%d",&num[i]);
		for(int i=1;i<=n;i++)
		{
			if(i%2==1)
			{
				if(num[i-1]!=num[i])
				{
					vec[num[i]].pb(i);
				}
				else
				{
					if(vec[num[i]].empty()) vec[num[i]].pb(i);
					else vec[num[i]][vec[num[i]].size()-1]=i;
				}
			}
			else
			{
				if(num[i-1]==num[i])
				{
					if(vec[num[i]].empty()) vec[num[i]].pb(i);
					else vec[num[i]][vec[num[i]].size()-1]=i;
				}
				else
				{
					vec[1-num[i]].pop_back();
					if(vec[num[i]].empty()) vec[num[i]].pb(i);
					else vec[num[i]][vec[num[i]].size()-1]=i;
				}
			}
		}
		int ret=0;
		if(vec[0].empty()) ret=0; else if(vec[1].empty()) ret=n;else{
		if(vec[0][0]>vec[1][0])
		{
			for(int j=0;j<vec[0].size();j++) ret+=vec[0][j]-vec[1][j];
		}
		else
		{
			ret+=vec[0][0];
			for(int j=1;j<vec[0].size();j++) ret+=vec[0][j]-vec[1][j-1];
		}}
		printf("%d\n",ret);
	}
}

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

int main(void){
    int n;
    cin >> n;

    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t.at(i);
    }

    int m;
    cin >> m;

    for(int i = 0; i < m; i ++){
        int p, x;
        cin >> p >> x;

        int ans = 0;
        for(int j = 0; j < n; j++){
            if(j != p-1){
                ans += t.at(j);
            }
            else{
                ans += x;
            }
        }
        cout << ans << endl;
    }
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a<b)System.out.println("a < b");
        else if(a>b)System.out.println("a > b");
        else System.out.println("a == b");
    }
}

Measured memory_bytes: 17156
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    string s, t;
    cin>>s>>t;
    a = s.size(), b = t.size();
    int mn = inf;
    for(int i=0;i<=a-b;++i) {
        int cnt=0;
        for(int j=0;j<b;++j) {
            if(s[i+j]!=t[j]) ++cnt;
        }
        mn = min(mn, cnt);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int W,H,x,y,r;
int main(){
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
	printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2092
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
int m[15000001];
void solve(){
    int n;
    cin>>n;
    int cnt=0;
    string ans="No";
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        if(l==r){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt>=3){
            ans="Yes";
        }
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3644
// https://atcoder.jp/contests/abc081/tasks/abc081_b

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

int main()
{
    int n;
    cin >> n;
    int ans = 40; // 2^40 > max(a)
    for (int i = 0; i < n; i++)
    {
        long a;
        int cnt = 0;
        cin >> a;
        while (a % 2 == 0)
        {
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }

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


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    bool flg=true;
    if(a<1||a>9)flg=false;
     if(b<1||b>9)flg=false;
     if(flg){
        cout << a*b<< endl;
     }
     else cout << -1 << endl;
    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

ll rtn_max(vector<ll> A, int b, int e){
    ll max_n = (-1)*pow(10,9);
    for(int i=b; i<e; i++){
        if(max_n < A[i]) max_n = A[i];
    }
    return max_n;
}

ll rtn_min(vector<ll> A, int b, int e){
    ll min_n = pow(10,9);
    for(int i=b; i<e; i++){
        if(min_n > A[i]) min_n = A[i];
    }
    return min_n;
}

int main()
{
    int n; cin >> n;
    vector<ll> A(n);
    rep(i,n){
        ll Ai; cin >> Ai;
        A[i] = Ai;
    }
    int q; cin >> q;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            int b, e; cin >> b >> e;
            int minn = rtn_min(A, b, e);
            cout << minn << endl;
        }else if(query == 1){
            int b, e; cin >> b >> e;
            int maxn = rtn_max(A, b, e);
            cout << maxn << endl;
        }
    }
}


Measured memory_bytes: 3168
n, q = gets.chomp.split.map(&:to_i)
result = []
p_list = {}
current_time = 0

n.times do
  p, t = gets.chomp.split
  p_list[p] = t.to_i
end

while !p_list.empty?
  p_list.each_pair do |pr, time|
    p_list[pr] = time - q
    if p_list[pr] <= 0
      current_time += time
      result << pr + " " + current_time.to_s
      p_list.delete(pr)
    else
      current_time += q
    end
  end
end

puts result

Measured memory_bytes: 13412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    string s,t;
    cin >> s >> t;

    ll result = INF;
    ll count;
    rep(i,s.size()-t.size()+1){
        count = 0;
        rep(j,t.size()){
            if(s[i+j] != t[j]) count++;
        }
        result = min(result,count);
    }
    
    cout << result;
}

Measured memory_bytes: 3600
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double n = scanner.nextDouble();
        int k = scanner.nextInt();
        double ans = 0.0;
        for(int i = 1; i <= n; i++){
            int p = 0;
            double cur = i;
            while(cur < k){
                cur *= 2;
                p++;
            }
            ans += Math.pow(0.5, p) * 1 / n;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define M 20
#define N 212345
pii a[N];
ll b[N] = {}; // ans
int c[N][M] = {}; // min

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d%d", &a[i].first, &a[i].second);
	sort(a, a+n);
	b[n] = 1;
	for(int i = n-1; i >= 0; i--){
		int j = 
			lower_bound(a, a+n, MP(a[i].first + a[i].second, INT_MIN)) - a;
		int &k = c[i][0] = i+1, h = i+1;
		DEBUG("  h = %d -> j = %d\n", h, j);
		for(int g = M-1; g >= 0; g--) if(h + (1<<g) <= j) {
			DEBUG("  h=%d g=%d\n", h, g);
			LAR(k, c[h][g]);
			h += 1<<g;
		}
		b[i] = (b[i+1] + b[k]) % 998244353;
		DEBUG("i = %d, j = %d, k = %d, b[i] = %lld\n", i, j, k, b[i]);
		FOR(g, 1, M) {
			if(i + (1<<g) > n) continue;
			c[i][g] = max(c[i][g-1], c[i + (1<<(g-1))][g-1]);
		}
	}
	printf("%lld\n", b[0]);
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
            x *= x % mod
            n >>= 1
        return res
    
    def cmb(n, r, mod):
        # 分子(n*(n-1)*...*(n-r+1))
        nume = 1
        for i in range(n-r+1, n+1):
            nume = nume * i % mod
        # 分母（1*2*...*r）
        deno = 1
        for j in range(1, r+1):
            deno = deno * j % mod
        d = modpow(deno, mod-2, mod)
        return nume * d % mod
    
    all_cmb = pow(2, n, mod) - 1
    bad_a = cmb(n, a, mod)
    bad_b = cmb(n, b, mod)    
    print((all_cmb-bad_a-bad_b) % mod)

if __name__ == '__main__':
    main()



Measured memory_bytes: 9204
/**
 * @author karayuu
 */
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    val y = readLine()!!.toInt()

    if (n <= k) {
        print((1..n).sumBy { x })
    } else {
        print((1..k).sumBy { x } + ((k + 1)..n).sumBy { y })
    }
}

Measured memory_bytes: 33536
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, M = il()
AB = iml(M)
s = {i: 0 for i in range(1, N + 1)}
for ab in AB:
    s[ab[0]] += 1
    s[ab[1]] += 1

for i in range(1, N + 1):
    print(s[i])


Measured memory_bytes: 3064
n,x,y=map(int,input().split())
ans={i:0 for i in range(n)}
dp=[[0]*n for _ in range(n)]
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if j<=x or y<=i:
      dp[i-1][j-1]=j-i  
    elif j<y:
      if i<=x:
        dp[i-1][j-1]=x-i+min(j-x,1+y-j)
      else:
        dp[i-1][j-1]=min(j-i,i-x+y-j+1)
    elif y<=j:
      if i<=x:
        dp[i-1][j-1]=x-i+1+j-y
      else:
        dp[i-1][j-1]=j-y+min(y-i,1+i-x)
    else:
      print("Error")
      print(i,j)
for i in range(0,n):
  for j in range(i,n):
    ans[dp[i][j]]+=1
for i in range(1,n):
  print(ans[i])

Measured memory_bytes: 79708
import java.util.Arrays;
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(true){
		String[] firstLine = s.nextLine().split(" ");
		int raw = Integer.parseInt(firstLine[0]);
		int column = Integer.parseInt(firstLine[1]);
		if(raw == 0 && column == 0)
			return;
		int[][] senbeiyakiki = new int[raw][column];
		for(int i=0 ; i<raw ; i++) {
			String[] line = s.nextLine().split(" ");
			for(int j=0 ; j<line.length ; j++) {
				senbeiyakiki[i][j] = Integer.parseInt(line[j]);
			}
		}
		System.out.println(solve(senbeiyakiki, raw, column, 0));
		}
	}

	public static int solve(int[][] senbeiyakiki, int raw, int column, int current) {
		if(current == raw) {
			int result = 0;
				int omo = 0;
				int ura = 0;
				for(int j=0 ; j<column ; j++) {
					for(int i=0 ; i<raw ; i++) {
						if(senbeiyakiki[i][j] == 1)
							omo++;
						if(senbeiyakiki[i][j] == 0)
							ura++;
					}
					if(omo >= ura)
						result += omo;
					else
						result += ura;
					omo = 0;
					ura = 0;
				}
			return result;
		}

		int[][] toggle = Arrays.copyOf(senbeiyakiki, senbeiyakiki.length);
		for(int i=0 ; i<column ; i++) {
			toggle[current][i] = toggle[current][i]==0 ? 1 : 0;
		}
		return Math.max(solve(senbeiyakiki, raw, column, current+1), solve(toggle, raw, column, current+1));
	}
}

Measured memory_bytes: 45272
while(n,m=gets.split.map &:to_i)[0]>0
r=0..n-1
t=r.map{gets.split.map &:to_f}
d=r.map{[1]*n}
(m-1).times{d.map!{|i|r.map{|j|x=0;r.map{|k|y=i[k]*t[k][j];x<y&&x=y};x}}}
puts"%.2f"%[d.flatten.max]
end

Measured memory_bytes: 9348
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int A = min(min(a,b),c);
    int C = max(max(a,b),c);
    int B = (a+b+c)-(A+C);
    cout << A << " ";
    cout << B << " ";
    cout << C << endl;
}


Measured memory_bytes: 3088
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int w=sc.nextInt();
		int n=sc.nextInt();
		int [] data=new int[w+1];
		for(int i=1;i<=w;i++){
			data[i]=i;
		}
		
		for(int i=0;i<n;i++){
			String bar=sc.next();
			String[] bs=bar.split(",");
			int a1=Integer.parseInt(bs[0]);
			int a2=Integer.parseInt(bs[1]);
			int tmp=data[a1];
			data[a1]=data[a2];
			data[a2]=tmp;
		}
		
		for(int i=1;i<=w;i++){
			ln(data[i]);
		}
	}
	public static String join(double[] array, String separator) {
		StringBuilder str = new StringBuilder(array[0] + "");
		for (int i = 1; i < array.length; i++) {
			str.append(separator).append(array[i] + "");
		}
		return str.toString();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        long sum = 0;

        foreach (var c in s)
        {
            sum += int.Parse(c.ToString());
        }

        string answer = (sum % 3 == 0) ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 33004
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
long long calc[3000000];
int main() {
#define int long long
	string s;
	cin >> s;
	REP(i, s.length() + 1) {
		calc[i] = -1;
	}
	for (int i = s.length() - 1; i >= 0; --i) {
		if (s[i] == '>') {
			calc[i + 1] = 0;
			if (i != s.length() - 1 && s[i + 1] == '>') {
				calc[i + 1] = calc[i + 2] + 1;
			}
		}
	}
	if (s[0] == '>') {
		calc[0] = calc[1] + 1;
	}
	else {
		calc[0] = 0;
	}
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == '<') {
			if (calc[i + 1] == -1) {
				calc[i + 1] = calc[i] + 1;
			}
			if (calc[i] >= calc[i + 1]) {
				calc[i + 1] = calc[i] + 1;
			}
		}
		else {
			if (calc[i] <= calc[i + 1]) {
				calc[i] = calc[i + 1] + 1;
			}
		}
	}
	long long ans = 0;
	REP(i, s.length() + 1) {
		ans += calc[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4996
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_032
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var groups = new List<List<int>>();
            int val;
            if (n % 2 == 0)
            {
                val = n + 1;
                WriteLine(n * (n - 2) / 2);
            }
            else
            {
                val = n;
                WriteLine((n - 1) * (n - 1) / 2);
            }
            for(int i = 1; i <= n; i++)
            {
                for(int j = i + 1; j <= n; j++)
                {
                    if (i + j == val) continue;

                    WriteLine(i + " " + j);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b;
	cin >> a >> b;
	if(b == 1) cout << 0 << endl;
	else if(a >= b) cout << 1 << endl;
	else cout << (b - a - 1) / (a - 1) + 2 << endl;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split(' '))

def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

def lcm(a,b):
	return a*b//gcd(a,b)

N = lcm(C,D)
A = A-1

s = A//C + A//D - A//N
t = B//C + B//D - B//N

print(B-t - (A-s))




Measured memory_bytes: 3060
N,X = map(int,input().split())
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(N,X):
  if N == 0:
    if X <= 0:
      return 0
    else:
      return 1
  elif X <= 1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
print(f(N,X))

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

int main() {
    vector <int> flag(8, 0);
    int N;
    int master = 0;
    cin >> N;
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        if (a<400) flag.at(0)=1;
        else if (a<800) flag.at(1)=1;
        else if (a<1200) flag.at(2)=1;
        else if (a<1600) flag.at(3)=1;
        else if (a<2000) flag.at(4)=1;
        else if (a<2400) flag.at(5)=1;
        else if (a<2800) flag.at(6)=1;
        else if (a<3200) flag.at(7)=1;
        else master++;
    }
    int min_ans = accumulate(flag.begin(), flag.end(), 0);
    int max_ans = min_ans+master;
    cout << max(1, min_ans) << " " << max_ans;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++) cin >> A[i];

	double ans = 1, deno = 0;
	for(int i = 0; i < N; i++) ans *= A[i];
	for(int i = 0; i < N; i++) deno += ans / A[i];
	cout << setprecision(12) << ans / deno;

	return 0;
}

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

const double PI=acos(-1.0);

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

int main() {
    int h, w;
    cin >> h >> w;
    char s[50][50];
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }

    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '.') continue;

            bool find = false;
            rep(d, 4) {
                int ni = i + dy[d];
                int nj = j + dx[d];

                if(s[ni][nj] == '#') find = true;
            }
            if(!find) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
        int n=sc.nextInt();
        if(n==0) break;
        double[] a=new double[n];
        double ave=0.0000000000;
        double sum=0.0000000000;
        for(int i=0;i<n;i++){
            a[i]=sc.nextDouble();
            sum+=a[i];
        }
        ave=(double)sum/n;
        double ans=0.0000000;
        for(int i=0;i<n;i++){
            ans+=(double)(a[i]-ave)*(a[i]-ave);
        }
        ans=(double)ans/n;
        ans=(double)Math.sqrt(ans);
        System.out.println(ans);
    }
    }
}


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

int main() {
  int x; cin >> x;
  int rem = x % 500;
  x -= rem;
  cout << x*2 + (rem/5)*5 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			int N = sc.nextInt();
			int X = sc.nextInt();
			int T = sc.nextInt();
			int cnt = N/X;
			
			if(Math.floorMod(N,X)!=0) {
				cnt++;
			}
			
			
			System.out.println(T*cnt);
	}	
}

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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int maxN = 5e5 + 5;
const ll INF = 1ll<<60;
int n;
ll k;
ll a[maxN];
ll b[maxN];
int c[maxN];
ll d[maxN];
int w = 41;
void cal(ll x)
{
	for(int i=1;i<=w;i++)
	{
		if(x%2 == 1)
			c[i] += 1;
		x/=2;
	}
}
ll f(ll x)
{
	ll res = 0;
	for(int i=1;i<=n;i++)
	{
		res += (x ^ a[i]);
	}
	return res;
}
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		cal(a[i]);
	}
	for(int i=1;i<=w;i++)
	{
		int pos = c[i];
		int neg = n - c[i];
		if(neg > pos)
			d[i] = 1;
		else
			d[i] = 0;
	}
	ll ans = 0;
	for(ll i=w;i>=1;i--)
	{
		ll cnt = (d[i]<<(i-1));
		if(ans + cnt <= k)
			ans = ans+cnt;
	//	cout<<ans<<endl;
	//	cout<<d[i]<<" "<<(d[i]<<i)<<endl;
	}
	//cout<<ans<<endl;
	cout<<f(ans)<<endl;
	return 0;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] d = new int[n][2];
		for (int i = 0; i < n; i++) {
			d[i][0] = sc.nextInt();
			d[i][1] = sc.nextInt();
		}
		sc.close();

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (d[i][0] == d[i][1]) {
				cnt++;
				if (cnt == 3) {
					System.out.println("Yes");
					return;
				}
			} else {
				cnt = 0;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 36020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                  \
  ifstream in("panasonic2020/panasonic2020_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll h, w;
  cin >> h >> w;

  ll cnt = 0;
  if (h == 1 || w == 1) {
    cnt = 1;
  } else {
    cnt = ((w / 2 + w % 2) + (w / 2)) * (h / 2) + (w / 2 + w % 2) * (h % 2);
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
Out =  S[:]
Temp = S[:]
while len(Temp) > 0:
	if Temp[0] == ")":
		Out.insert(0,"(")
		del Temp[0]
	elif Temp[0] == "(":
		i = 0
		for j in range(len(Temp)):
			if Temp[j] == ")":
				del Temp[j]
				del Temp[0]
				i += 1
				break
		if i == 0:
			Out.append(")")
			del Temp[0]
print(''.join(Out))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#pragma GCC optimize ("O3")
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 2e5+9;
const double pi=3.14159265358979323846264;
const int inf = 2e9;
const ll mod = 998244353;
ll op[maxn],pq[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<=n;++i) cin>>op[i];
    if(!n&&op[0]==1){
        cout<<1;
        return 0;
    }
    if(op[0]){
        cout<<-1;
        return 0;
    }
    for(int i=n-1;i>=1;--i){
        pq[i]=pq[i+1]+op[i+1];
    }
//    for(int i=1;i<=n;++i) cout<<pq[i]<<",";
//    cout<<endl;
    ll la=1,fg=1,ans=1;
    for(int i=1;i<=n;++i){
        if(op[i]>la*2){
            fg=0;
            break;
        }
        la=min(pq[i],la*2-op[i]);
        ans+=la+op[i];
//        cout<<la<<","<<endl;
    }
    if(!fg) cout<<-1;
    else cout<<ans;
    return 0;
}


Measured memory_bytes: 5172
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iterator>
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5+50;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f first
#define s second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

 
int main(){
 
   ios::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin>>str;
  int i=0;
   int x=count(str.begin(),str.end(),'R');
     if(x==0)
        cout<<0<<endl;
    else if(x==1)
        cout<<1<<endl;
     else  if(x==3)
         cout<<3<<endl;
     else if(x==2 && ( (int)str[i]==(int)str[i+1] || (int)str[i+1]==(int)str[i+2] ))
         cout<<2<<endl;
     else
        cout<<1<<endl;
        

}

Measured memory_bytes: 3632
(let ((n (read))
    (s (read-line)))
    (if (not (zerop (rem n 2)))
        (princ "No")
        (if (equal (subseq s 0 (/ n 2)) (subseq s (/ n 2) n))
            (princ "Yes")
            (princ "No")
        )
    )
)

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

int main()
{
  int n;
  int l, s;
  vector<int> vi1;
  vector<int> vi2;
  int cnt;

  while(1){
    cin >> n;
    if(n == 0) break;

    cnt = 0;

    while(1){
      l = s = 0;
      vi1.clear();
      vi2.clear();
      if(n == 6174){
	cout << cnt << endl;
	break;
      }else if(n == 0){
	cout << "NA" << endl;
	break;
      }

      for(int i = 0;i < 4;++i){
	vi1.push_back(n % 10);
	vi2.push_back(n % 10);
	n /= 10;
      }
      
      //l,sを求める
      sort(vi1.begin(), vi1.end());
      sort(vi2.begin(), vi2.end(), greater<int>());

      /*
      cout << "vi1:";
      for(int i = 0;i < 4;++i){
	cout << vi1[i] << ' ';
      }
      cout << endl;
      cout << "vi2:";
      for(int i = 0;i < 4;++i){
	cout << vi2[i] << ' ';
      }
      cout << endl;
      */
      
      for(int i = 0;i < 4;++i){
	l *= 10;
	l += vi1[i];
	
	s *= 10;
	s += vi2[i];
      }

      /*
      cout << s << "-" << l << "=" << s - l << endl;
      */
      
      //新しいNを求める
      n = s - l;
      ++cnt;
    }

  }

  return 0;
}



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

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    for(ll i=1;i<=k;++i){
        vector<ll>s(n+1,0);
        for(ll j=0;j<n;++j){
            s[max(0LL,j-a[j])]+=1;
            s[min(n,j+a[j]+1)]-=1;
        }
        for(ll j=1;j<=n;++j){
            s[j]+=s[j-1];
        }
        bool flag=0;
        for(ll j=0;j<n;++j){
            a[j]=s[j];
            if(a[j]<n)flag=1;
        }
        if(flag==0){
            break;
        }
    }
    for(auto x:a){
        cout<<x<<" ";
    }
}

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

int main(){
  string a, b;
  cin >> a >> b;
  if(a == b){puts("Yes"); return 0;}
  int len = (int)a.length();
  for(int i = 0; i < len;++i){
    char last = a[len - 1];
    string temp = a.substr(0,len - 1);
    a = last + temp;
    if(a == b){
      puts("Yes");
      return 0;
    }
  }
  if(a == b) puts("Yes");
  else puts("No");
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a==1)	a += 13;
	if(b==1)	b += 13;
	
	if(a>b)		cout << "Alice" << endl;
	else if(a<b)	cout << "Bob" << endl;
	else		cout << "Draw" << endl;

	return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll child[100010] = {};
bool win = false;
ll N;

void dfs(ll cur, ll par){
    child[cur] = 1;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur);
        child[cur] += child[e];
    }
}

void dfs2(ll cur, ll par){
    ll cnt = 0;
    for(auto &e: tree[cur]){
        if(child[e] % 2 == 1) cnt++;
    }
    if(cnt >= 2) win = true;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        ll tmp = child[e];
        child[cur] -= child[e];
        child[e] = N;
        dfs2(e, cur);
        child[e] = tmp;
        child[cur] += child[e];
    }
}

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

    rep(i,0,N-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    dfs(0, -1);
    dfs2(0,-1);
    if(win){
        print("First");
    }else{
        print("Second");
    }
    
    

}

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

using namespace std;
const int maxn=3005;
 
long double dp[3005][3005][2],a[maxn];
int n;


int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%Lf",&a[i]);
	dp[0][0][0]=dp[0][0][1]=1;
	for(int i=1;i<=n;i++){
		dp[i][0][0]=dp[i-1][0][0]*(1-a[i]);
		dp[i][0][1]=dp[i-1][0][1]*a[i];
		for(int j=1;j<=i;j++){
			dp[i][j][0]=dp[i-1][j][0]*(1-a[i])+dp[i-1][i-j][1]*a[i];
			dp[i][j][1]=dp[i-1][j][1]*a[i]+(dp[i-1][i-j][0]*(1-a[i]));
		}
	}
	long double ans=0;
	for(int i=(n/2)+1;i<=n;i++) ans+=dp[n][i][0];
	printf("%.13Lf\n",ans);
}

Measured memory_bytes: 280064
#include "stdio.h"

int main()
{
    int a, b;
    scanf("%d", &a);
    b = a % 10;
    if(b == 2 || b == 4 ||b == 5 ||b == 7 ||b == 9) printf("hon");
    else if(b == 0 ||b == 1 ||b == 6 ||b == 8) printf("pon");
    else printf("bon");
    return 0;
}


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

typedef long long ll;
using namespace std;

int main()
{
    ll a,b,k,z;
    cin>>a>>b>>k;

    if(a<k)
    {
        z=b-(k-a);
        if(z<0)
        {
            z=0;
        }
        cout<<0<<" "<<z<<endl;
    }
    else
    {
        cout<<a-k<<" "<<b<<endl;
    }




    return 0;
}


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

int main(){
  int n;
  int a;
  cin>>n;
  vector<int> card;
  for(int i=0;i<n;i++){
    cin>>a;
    card.push_back(a);
  }
  sort(card.begin(),card.end(),greater<int>());
  int alice=0;
  int bob=0;
  int i=0;
  while(i<n){
    alice+=card[i];
    i++;
    if(i>=n) break;
    bob+=card[i];
    i++;
  }
  cout<<alice-bob<<endl;
}


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

int main(){
    int a[3];
    for(int i=0;i<3;i++)cin >> a[i];
    sort(a,a+3);
    int k;
    cin >> k;
    for(int i=0;i<k;i++){
        a[2]*=2;
    }
    cout << a[0]+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i < 10; i++) {
        for(int j = i; j < 10; j++) {
            if(i * j == n) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]

N = int(s[0])
S = list(s[1])

# Process
M = 0

for i in range(1,N):
    if S[i-1] == S[i]:
        M += 1

N = N - M

# Output
print(N)

Measured memory_bytes: 4084