akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const int MAXN = 10, MAXM = 1000;

int h, w, k;
int a[MAXN+1][MAXM+1];

void sabiraj(vi &v1, vi &v2)
{
    int n = (int)v1.size();

    for(int i = 0; i < n; ++i)
    {
        v1[i] += v2[i];
    }
}

int seci(int maska)
{
    vi gdeSiSekao;

    for(int i = 0; i < 9; ++i)
    {
        if((1 << i)&maska)
        {
            gdeSiSekao.pb(i);
        }
    }

    int velicina = (int)gdeSiSekao.size()+1;

    vi beleziZaSvakog(velicina);
    int brojac = 0;
    for(int i = 0; i < w; ++i)
    {
        vi trenutno(velicina);
        int temp = 0;
        int pokazivac = 0;

        for(int j = 0; j < h; ++j)
        {
            temp += (a[j][i] == 1);
            if(temp > k)return -1;
            if((j == h-1) || (pokazivac < velicina-1 && j == gdeSiSekao[pokazivac]))
            {
                trenutno[pokazivac++] = temp;
                temp = 0;
            }
        }

        sabiraj(beleziZaSvakog, trenutno);
        bool jelTacno = false;
        for(int j = 0; j < velicina; ++j)
        {
            if(beleziZaSvakog[j] > k)
            {
                jelTacno = true;
                break;
            }
        }

        if(jelTacno)
        {
            beleziZaSvakog = trenutno;
            ++brojac;
        }
    }

    return brojac;
}

int main()
{
    cin >> h >> w >> k;

    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            char c;
            cin >> c;
            a[i][j] = c - '0';
        }
    }

    int resenje = 1e9;

    for(int i = 0; i < (1<<(h-1)); ++i)
    {
        int trenutno = seci(i);
        if(trenutno<0)continue;
        trenutno += __builtin_popcount(i);
        resenje = min(resenje, trenutno);
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int s;
	cin >> s;
	vector <ll> data(s);
	
	for (int i = 0;i<s;i++)
	{
		cin >> data[i];
	}
	map <ll, ll> box;
	for (auto x: data)
	{
		box[x - 1]++;
		box[x]++;
		box[x+1]++;
	}
	ll ans = 0;
	for (auto x : box)
	{
		ans = max(ans, x.second);
	}
	cout << ans << endl;

	return 0;

}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;
    cin>>n;
    vi vec;
    int maxi=INT_MIN;
    FOR(i,0,n)
    {
    	int x;cin>>x;
    	vec.pb(x);
    	if(x>maxi)
    		maxi=x;
    }
    int cnt=0;
    //cout<<maxi<<"\n";
    sort(all(vec));
    FOR(i,1,maxi+1)
    {
    	int j=0,k=n-1,key=i;
    	while(j<k)
    	{
    		int m = (j+k)/2;
    		if(vec[m]<key)
    			j=m+1;
    		else
    			k=m;
    	}
    	int a = j,b=n-j;
    	//cout<<key<<" "<<j<<"\n";
    	if(a==b)
    		++cnt;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3708
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
using namespace std;
int inf = 1000000000;

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

struct Dist{
  int to, from, dist;
};

int main(){
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> v(n, inf);
  vector<Dist> c(m);
  for(int i=0; i<m; i++){
    int s, t, d;
    cin >> s >> t >> d;
    c[i].to = t; c[i].from = s; c[i].dist = d;
  }

  v[r] = 0;

  while( true ){
    bool f = false;
    for(int i=0; i<c.size(); i++){
      Dist d = c[i];
      if( v[d.from] != inf && v[d.to] > v[d.from] + d.dist ){
        v[d.to] = v[d.from] + d.dist;
        f = true;
      }
    }
    if( !f ) break;

  }

  for(int i=0; i<n; i++){
    if( v[i] == inf ) cout << "INF" << endl;
    else cout << v[i] << endl;
  }

  return 0;
}





// EOF

Measured memory_bytes: 8772
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
	sum+=a[i];
	cout<<sum;
	return 0;
}

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

int main(){
   long int n;cin>>n;
   long int min=99999999999999;
   int f;
   for(long int i=1;i<=sqrt(n);i++){
       if(n%i==0){
            long int j=n/i;
            string a=to_string(i);
            string b=to_string(j);
            //cout << i << " " << j << endl;
            f=max(a.size(),b.size());
            if(min>f) min=f;
       }
   }
   cout << min << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let n = s.len();
    let mut mark = vec![];
    let mut rev_mark = vec![];
    for i in 0..n - 1 {
        if s[i] != s[i + 1] {
            mark.push(i);
        }
    }
    for i in 1..n {
        if s[i] != s[i - 1] {
            rev_mark.push(n - i - 1);
        }
    }
    rev_mark.reverse();

    let mut answers = vec![0; n];
    for i in 0..n {
        if s[i] == 'R' {
            let nearest_mark = mark[mark.lower_bound(&i)];
            if (nearest_mark - i) % 2 == 0 {
                answers[nearest_mark] += 1;
            } else {
                answers[nearest_mark + 1] += 1;
            }
        } else {
            let nearest_mark = n - rev_mark[rev_mark.lower_bound(&(n - i - 1))] - 1;
            // debug!(i, nearest_mark);
            if (i - nearest_mark) % 2 == 0 {
                answers[nearest_mark] += 1;
            } else {
                answers[nearest_mark - 1] += 1;
            }
        }
    }
    print_array(&answers);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 12668
n = gets.to_i
cards = gets.split.map(&:to_i).sort.reverse
alice = 0
bob = 0

loop do
  if cards.length != 0
    alice += cards.pop
  else
    break
  end

  if cards.length != 0
    bob += cards.pop
  else
    break
  end
end

puts (alice - bob).abs


Measured memory_bytes: 1788
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math

def fast_comb(a,b,mod):
    up = reduce(lambda x,y: x*y%mod, range(a,a-b,-1))
    down = reduce(lambda x,y: x*y%mod, range(1,b+1))
    return (up * pow(down, mod-2, mod)) % mod

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def readlines(n):
    for _ in range(n):
        query = input().split()
        yield iter(query)

def main():
    a = input().strip()
    q = int(input())

    deq = deque(a)
    first = True
    initial = True
    for query in readlines(q):
        t = next(query)
        if t == '1':
            if first:
                continue
            initial = not initial
            continue

        f, c = query
        if initial:
            if f == '1':
                deq.appendleft(c)
            else:
                deq.append(c)
        else:
            if f == '1':
                deq.append(c)
            else:
                deq.appendleft(c)

        first = False

    print("".join(deq) if initial else "".join(reversed(deq)))



main()

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

using namespace std;

int main()
{
    char c;
    cin >> c;

    switch(c){
    case 'a': cout << "vowel" << endl; break;
    case 'e': cout << "vowel" << endl; break;
    case 'i': cout << "vowel" << endl; break;
    case 'o': cout << "vowel" << endl; break;
    case 'u': cout << "vowel" << endl; break;
    default: cout << "consonant" << endl;
    }

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    int x = 0;
    rep(i,S.size()){
        if(S[i] == 'I') x++;
        else x--;
        ans = max(ans,x);
    }
    cout << ans << endl;
}

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

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b;std::cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        std::string s=std::to_string(i);
        ans+=s==std::string(s.rbegin(),s.rend());
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[10001];
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n;
  for(int x=1;x*x<=n;x++)
    for(int y=1;x*x+y*y+x*y<=n;y++)
      for(int z=1;x*x+y*y+z*z+x*y+x*z+y*z<=n;z++)
        a[x*x+y*y+z*z+x*y+x*z+y*z]++;
  for(int i=1;i<=n;i++)
    cout<<a[i]<<'\n';
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define max1(a,b) a > b ? a : b;
using namespace std;
typedef long long ll;
ll a, b, x, y,sum;
int main()
{
	ios::sync_with_stdio(false);
	cin >> b;
	a = 100;
	int year = 0;
	while (a < b)
	{
		a +=(ll)a * 0.01;
		year++;
	}
	cout << year;
	return 0;

}

Measured memory_bytes: 3640
import sys
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
s=sum(A)-sum(B)
if s<0:
    print(-1)
    sys.exit()
D=[]
inf=float("inf")
for i in range(N):
    num=A[i]-B[i]
    if num<0:
        D.append(inf)
    else:
        D.append(num)
D.sort()
cnt=0
for i in range(N):
    s-=D[i]
    if s>=0:
        cnt+=1
    else:
        break
print(N-cnt)

Measured memory_bytes: 85040
N=int(input())
from collections import defaultdict
dic=defaultdict(int)
for _ in range(N):
    dic[input()]+=1

print("AC x "+str(dic["AC"]))
print("WA x "+str(dic["WA"]))
print("TLE x "+str(dic["TLE"]))
print("RE x "+str(dic["RE"]))

Measured memory_bytes: 9476
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int K; cin >> K;
    string s; cin >> s;
    int l = s.size();
    if (l <= K) {
        cout << s << endl;
    }
    else {
        rep(i,K) cout << s[i];
        cout << "..." << endl;
    }


    
    return 0;
}






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

int main() {
  int v, b;
  while (cin >> v >> b) {
    if (v == 1) {
      cout << 1 << endl;
      continue; // bug:break!
    }
    vector<int> label(v);
    label[0] = 2;
    label[1] = 3;
    for (int i = 2; i < v; i++) {
      label[i] = (label[i - 1] + label[i - 2]) % 1001;
    }
    sort(label.begin(), label.end());
    int ans = 1;
    for (int i = 1; i < v; i++) {
      if (label[i] - label[i - 1] >= b)
        ans++;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3156
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<cwctype>
#include<algorithm>
#include<math.h>

using namespace std;

bool data[1000000001]={false};

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		data[x]=true;
	}

	int q;
	cin>>q;
	int count=0;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		if(data[x])count++;
	}
	cout<<count<<endl;
	return 0;
}

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

int main() {
  int k;
  cin >> k;
  long long sum =0;
  for(int i=1;i<k+1;i++){
    for(int j=1;j<k+1;j++){
      for(int l=1;l<k+1;l++){
        long long g = gcd(i,j);
        g = gcd(g,l);
        sum+=g;
      }
    }
  }
  cout << sum << endl;
}
      


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

int main()
{
	int n, k;
	cin >> n;
	set<int> mochi;
	
	for (int i = 0; i < n; i++)
	{
		cin >> k;
		mochi.insert(k);
	}
	
	cout << mochi.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#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(){
  string a;
cin >> a;
 
if (a == "AAA" || a == "BBB"){
  cout << "No" << endl;
}
else{
   cout << "Yes" << endl;
}
 
return 0;
  
}

Measured memory_bytes: 3572
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();
    if s.len() == 1{
        println!("0");
        return;
    }

    let mut ans = 0;

    let mut i = 0;
    while i < s.len(){
        let mut j = 0;
        while i + j < s.len() && s[i] == s[i+j]{
            j += 1;
        }
        i += j;
        ans += 1;
    }

    println!("{}", ans-1);
}


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

int main(){
  int S, a, b;
  cin >> S;
  a = S/100;
  b = S - a*100;

  
  if(0 < a && a <= 12 && 0 < b && b <= 12) cout << "AMBIGUOUS" << endl;
  else if(0 < b && b <= 12) cout << "YYMM" << endl;
  else if(0 < a && a <= 12) cout << "MMYY" << endl;
  else cout << "NA" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long n,q[10],v[10],a,b;
	long long x,y,c,d;
	while(true){
	cin>>n;
	if(n==0)break;
	cin>>a>>b;
	q[0]=a,v[0]=b;
	c=q[0],d=v[0];
	while(true){
		if(d>c){
			long long tmp=c;
			c=d;
			d=tmp;
		}
		if(d==c)break;
		c=c%d;
		if(c==0){c=d;break;}
	}
	q[0]/=c,v[0]/=c;
	a/=c,b/=c;
	for(int i=1;i<n;i++){
		cin>>q[i]>>v[i];
		c=q[i],d=v[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		q[i]/=c,v[i]/=c;
		c=b,d=v[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		x=c;
		c=a,d=q[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		y=c;
		a=a*q[i]/y;
		b=x;
		c=a,d=b;
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		a/=c,b/=c;
	}
	for(int i=0;i<n;i++){
		long long ans=v[i]*a;
		ans/=q[i]*b;
		cout<<ans<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1156
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        char[][] map = Enumerable.Repeat(0, hw[0]).Select(_ => Console.ReadLine().ToArray()).ToArray();
        if (map[0][0] == '.') goto invalid;
        map[0][0] = '.';
        int y = 0;
        int x = 0;
        while (x != hw[1] || y != hw[0])
        {
            if (y + 1 < hw[0] && map[y + 1][x] == '#')
            {
                y++;
                map[y][x] = '.';
            }
            else if (x + 1 < hw[1] && map[y][x + 1] == '#')
            {
                x++;
                map[y][x] = '.';
            }
            else
            {
                break;
            }
        }
        if(map.All(a => a.All(b => b == '.')))
        {
            Console.WriteLine("Possible");
            return;
        }
    invalid:;
        Console.WriteLine("Impossible");
    }
}


Measured memory_bytes: 13524
import itertools

n = int(input())
N = [i for i in range(1,n+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

for i, j in enumerate(itertools.permutations(N)):
    if j == P:
        a = i + 1
    elif j == Q:
        b = i + 1
if P == Q:
    b = a

print(abs(a - b))

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n;cin>>n;

    VL result(n+1);
    FOR(x,1,100){
        FOR(y,1,100){
            FOR(z,1,100){
                LL t = x*x+y*y+z*z+x*y+y*z+z*x;
                if(t <= n){
                    result[t]++; 
                }
            }
        }
    }
    FOR(i,1,n+1){
        cout<<result[i]<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main() {
    int n, temp, ans = 0;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        cin >> temp;
        mp[temp]++;
    }
    for(pair<int, int> p : mp) {
        if(p.second >= p.first) ans += p.second - p.first;
        else ans += p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll ,ll>> a(n);
    rep(i,0,n-1){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    ll hoge = 0;
    ll val = 0;
    rep(i,0,n-1){
        rep(j,0,a[i].second-1){
            if(hoge<m){
                val += a[i].first;
                hoge++;
            }
            else{
                cout<<val<<endl;
                return 0;
            }
        }
    }
    cout<<val<<endl;
    return 0;
}

Measured memory_bytes: 1792
x=int(input())
s=round(2*abs(x)**(1/5))
for a in range(s,0,-1):
    b=(a**5-x)
    if b<0:
        b=-(round(abs(b)**(1/5),7))
        if b.is_integer():
            b=int(b)
            print("{} {}".format(a,b))
            exit()

    else:
        b=(round(abs(b)**(1/5),7))
        if b.is_integer():
            b=int(b)
            print("{} {}".format(a,b))
            exit()

#

Measured memory_bytes: 62440
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int dp[102][5][5][5];

signed main() {
	int n;
	cin >> n;
	rep(j, 4) {
		rep(k, 4) {
			rep(l, 4) {
				if (j == 0 && k == 2 && l == 1) continue;
				if (j == 0 && k == 1 && l == 2) continue;
				if (j == 2 && k == 0 && l == 1) continue;
				dp[3][j][k][l] = 1;
			}
		}
	}
	for (int now = 4; now <= n; now++) {
		rep(i, 4) {
			rep(j, 4) {
				rep(k, 4) {
					rep(l, 4) {
						if (j == 0 && k == 2 && l == 1) continue;
						if (j == 0 && k == 1 && l == 2) continue;
						if (j == 2 && k == 0 && l == 1) continue;
						if (i == 0 && k == 2 && l == 1) continue;
						if (i == 0 && j == 2 && l == 1) continue;
						dp[now][j][k][l] += dp[now - 1][i][j][k];
						dp[now][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	int ans = 0;
	rep(i, 4) {
		rep(j, 4) {
			rep(k, 4) {
				ans += dp[n][i][j][k];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
  int N, A, B;

  cin >> N;
  cin >> A;
  cin >> B;

  int total;
  int s;
  int count = 0;
  int all = 0;

  for(int i = 1; i <= N; i++) {
    total = 0;
    s = i;
    for(int j = 0; j < 5; j++) {
      total += s % 10;
      s /= 10;
    }
    if(A <= total && total <= B) {
      all += i;
    }
  }

  cout << all << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,m,x;
const int maxn = 1e5+10;
long long a[maxn],b[maxn];
int main(){
    long long i,j,k;
    long long ans;
    long long now;
    long long comm;
    scanf("%d",&n);
        ans = 0;
        now = 0;
        for(i=1;i<=n;i++){
            scanf("%lld%lld",&a[i],&b[i]);
        }
        
        for(i=n;i>=1;i--){
            a[i] += ans;
            for(j=a[i]/b[i];;j++){
                if(j*b[i]>=a[i]){
                    break;
                }
            }
            comm = j*b[i] - a[i];
            ans += comm;
        }
        printf("%lld\n",ans);
    
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int n;
int ans = 0;
void dfs(int now, int a, int b, int c) {
	if (now > n)return;
	if (a&&b&&c) {
		ans++;
	}
	dfs(now * 10 + 3, 1, b, c);
	dfs(now * 10 + 5, a, 1, c);
	dfs(now * 10 + 7, a, b, 1);
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
ans=[[] for _ in range(100)]
for i in range(100):
    for j in range(100):
        if i<=49:
            ans[i].append(".")
        else:
            ans[i].append("#")
a-=1
b-=1
for i in range(0,50,2):
    for j in range(0,100,2):
        if b>0:
            ans[i][j]="#"
            b-=1
for i in range(51,100,2):
    for j in range(0,100,2):
        if a>0:
            ans[i][j]="."
            a-=1
print(100,100)
for i in range(100):
    print("".join(ans[i]))

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

#define endl "\n"
#define ll long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define read(v) for(auto &it:v) cin>>it;
#define out(v) for(auto &it:v) cout<<it<<" ";
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vll;

#define deb(x) cout << ">" << #x << '=' << x << endl;
#define setbits(n) __builtin_popcountll(n)
#define done {cout<<"-1"<<endl; return;}

#define inf INT_MAX
#define ninf INT_MIN
const ll N = 1e5 + 5;
#define MOD 1000000007
vector<int> dp(2005, -1);
long long solve(int n) {
	//if (n == 0) return 1;
	if (n < 3) return 0;
	else if (n < 5) return 1;
	if (dp[n] != -1) return dp[n];
	long long ans = 0;
	for (int i = 3; i <= n; i++) {
		ans += solve(n - i) ;
		ans %= MOD;
	}
	dp[n] = 1 + ans;
	return dp[n];

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputc.txt", "r", stdin);
	freopen("outputc.txt", "w", stdout);
#endif
	int t = 1;
	cin >> t;
	cout << solve(t) << endl;
	//for (int i = 0; i <= t; i++) cout << i << " " << dp[i] << endl;
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3816
#include<iostream>

using namespace std;

int main(void) {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int res = 0;
  for (int i = 0; i > -1; i++) {
    if (i * r > n) break;
    for (int j = 0; j > -1; j++) {
      if (i * r + j * g > n) break;
      if ((n - (i * r) - (j * g)) % b == 0) res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main() {
	int a[5];
	int b; cin >> b;
	for (int i = 0; i < 4; i++) {
		a[i] = b%10;
		
		b = b / 10;
		
	}
	b = 0;
	a[4] = 10000;
	for (int i = 0; i < 4; i++) {
		if (a[i] == a[i + 1]) {
			b += 1;
		}
	}
	if (b != 0) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}
	return 0;
}

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

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int g = A[0], m = A[0];
  for (int i = 1; i < N; i++)
  {
    g = __gcd(g, A[i]);
    m = max(m, A[i]);
  }
  if (K <= m && K % g == 0)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;

  return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		
		var dp = new long[s.Length + 1, 13];
		dp[0,0]=1;
		for(int i = 0; i < s.Length; i++)
		{
			int c = (int)(s[i] - '0');
			for(int j = 0; j < 13; j++)
			{
				if(s[i] == '?') 
				{
					for(int k = 0; k <= 9; k++)
					{
						dp[i+1, (j*10+k)%13] += dp[i, j];
						dp[i+1, (j*10+k)%13] %= Giri;
					}
				}
				else
				{
					dp[i+1, (j*10+c)%13] += dp[i, j];
					dp[i+1, (j*10+c)%13] %= Giri;
				
				}
			}
		}
		
		Console.WriteLine(dp[s.Length, 5] % Giri);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 21472
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
    ll a,b,n ;
    cin >> a>> b>>n ;
    if(n<b-1)
    cout <<floor((a*n)/b)<<endl ;
    else
  cout <<floor((a*(b-1))/b)<<endl ; 
    return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	//入力
	ll h , n ;
	cin >> h >> n ;
	vector<pair<ll,ll>> p(n);//攻撃力、消費MP
	rep(i,n) cin >> p[i].first >> p[i].second ; 

	vector<vector<ll>> dp(n,vector<ll> (h+1,INF));
	//	dp[i][j]　i番目までの魔法で、jのダメージを与えるときの消費MPの最小値
	//solve
	//dpをINFで埋める
	rep(i,n) dp[i][0] = 0 ; //0のダメージを与えるときのMPは0

	rep(i,n){
		ll atk = p[i].first ;
		ll mp = p[i].second ;
		rep(j,h+1){
			if(j == 0 ) continue;
			if ( j <= atk ){
				dp[i][j] = mp ;
				if( i != 0 ) chmin(dp[i][j],dp[i-1][j]);
			} else { 
				chmin(dp[i][j],dp[i][j-atk]+mp);
				if( i != 0) chmin(dp[i][j],dp[i-1][j]);
			}
		}
	}
//	rep(i,n){
//		rep(j,h+1){
//			cout << dp[i][j] <<" " ;
//		}
//		cout << endl;
//	}
//	cout << "above is check" << endl;
	cout << dp[n-1][h] << endl;

}


Measured memory_bytes: 78464
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(); long b = sc.nextLong(); long n = sc.nextLong(); long ans;
        if (n >= b - 1) {
            ans = (a * (b-1))/b - a * ((b-1) / b);
        } else {
            ans = (a * n)/b - a * (n / b);
        }
        System.out.println(ans);
    }


}

Measured memory_bytes: 35784
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[5]={0};
    scanf("%s", str);

    if(strlen(str)==2) {
        printf("%s\n", str);
    }
    else {
        char tmp = str[0];
        str[0]=str[2];
        str[2]=tmp;
        printf("%s\n", str);
    }

    //printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n;
  cin >> n;
  
  bool flag = false;
  for (int x = 1; x <= 50000; x++) {
    if ((int)(x * 1.08) == n) {
      cout << x << endl;
      flag = true;
      break;
    }
  }
  if (!flag)
    cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    string w;
    cin >> w;

    int cnt[30] = {0};
    for(int i = 0; i < w.size(); ++i){
        cnt[w[i]-'a']++;
    } 

    bool can = true;

    for(int i = 0; i < 30; ++i){
        if(cnt[i] % 2 == 1) can = false;
    } 

    if(can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
const int maxx = 110;
int n, m[maxx][maxx];
int u, num, v;
int d[maxx], f[maxx];
int flag[maxx];
int nowtime = 1;

void dfs(int u) {

	// ??\?????¶??´
	flag[u] = 1;
	d[u] = nowtime++;
	for (int i = 1; i <= n; i++) {
		if (flag[i] == 0 && m[u][i] == 1) {
			dfs(i);
		}
	}
	//????????¶??´
	f[u] = nowtime++;
}

int main()
{

	scanf("%d", &n);
	memset(m, 0, sizeof(m));
	memset(f, 0, sizeof(f));
	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &u, &num);
		for (int j = 1; j <= num; j++) {
			scanf("%d", &v);
			m[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if(flag[i] == 0)
			dfs(i);
	}
	for (int i = 1; i <= n; i++) {
		printf("%d %d %d\n", i, d[i], f[i]);
	}
	return 0;
}

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

using namespace std;

int main(){
    int n, k, score;
    long double sum, kakuritu;
    sum = 0.0;
    cin >> n >> k;
    for (int i = 0; i < n;i++){
        score = i + 1;
        kakuritu = 1.0 / (long double)n;
        while(score <k){
            kakuritu *=0.5;
            score = score*2;
        }
        sum += kakuritu;
    }
    cout << setprecision(10);
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  int n;cin>>n;
  ll ans = 1;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  rep(i,n)if(a[i] == 0){
    print(0);return 0;
  }

  rep(i,n){
    if(a[i] <= 1000000000000000000/ans)ans *= a[i];
    else {
      print(-1);
      return 0;
    }
  }
  print(ans);
  
  return 0;
}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n+2);
  A[0]=0;
  A[n+1]=0;
  ll sum=0;
  for(int i=1;i<=n;i++){
    cin>>A[i];
    sum+=abs(A[i]-A[i-1]);
  }
  sum+=abs(A[n+1]-A[n]);
  for(int i=1;i<=n;i++){
    if(A[i-1]<=A[i]&&A[i]<=A[i+1]){
      cout<<sum<<endl;
    }else if(A[i-1]>=A[i]&&A[i]>=A[i+1]){
      cout<<sum<<endl;
    }else{
      cout<<sum+abs(A[i+1]-A[i-1])-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <climits>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (int)1e9
#define INFL (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n;
vector<int> c;
int q;
vector<int> box;
vector<int> t, x, d;
/**********************************************/

signed main(){
    cin >> n;
    c.resize(n);
    box.resize(n);
    REP(i, n) cin >> c[i];
    cin >> q;
    t.resize(q);
    x.resize(q);
    d.resize(q);
REP(i, q){
        cin >> t[i] >> x[i] >> d[i];
}
    REP(i, q){
        if(t[i] == 1 && box[x[i]-1] + d[i] > c[x[i]-1]){
            cout << x[i] << endl;
            return 0;
        }else if(t[i] == 2 && box[x[i]-1] - d[i] < 0){
            cout << x[i] << endl;
            return 0;
        }

        if(t[i] == 1){
            box[x[i]-1] += d[i];
        }else{
            box[x[i]-1] -= d[i];
        }
    }
    cout << "0" << endl;
}



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

int main() {
  
string s;
int n,k;
cin>>n>>k>>s;
if(s.at(k-1)=='A'){
    s.at(k-1)='a';
}
if(s.at(k-1)=='B'){
    s.at(k-1)='b';
}
if(s.at(k-1)=='C'){
    s.at(k-1)='c';
}
cout<<s<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>

#define N 20
#define Q 200

int A[N],m[Q];
int n,q,i;
int flag;

void solve(int i,int x){
   
  if(i == n){
    if(x == 0) 
      flag = 1;
  }
  else{
    solve(i+1, x-A[i]);
    solve(i+1,x);
  }
}

int main(){
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d",&m[i]);
    flag = 0;
    solve(0, m[i]);
    if(flag==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 580
d = ['a','b','c','d','e','f','g','h','i','j']

n = int(input())

result = []

def fig(s, mx):
    if len(s) == n:
        result.append(s)
        return
    
    for i in range(mx+1):
        if i == mx:
            mx += 1
        fig(s + d[i], mx)

fig('', 0)
result.sort()

for r in result:
    print(''.join(r))
    


Measured memory_bytes: 12668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(str);
		if (str.length() == 1) {
			System.out.println(str);
		} else if (str.charAt(0) != '9') {
			int cnt = 0;
			for (int i = 1; i < str.length() && cnt == 0; i++) {
				if (str.charAt(i) != '9')
					cnt++;
			}
			System.out.println(9 * (str.length() - 1) + (str.charAt(0) - '0') - cnt);
		} else {
			int cnt = 0;
			for (int i = 0; i < str.length() && cnt == 0; i++) {
				if (str.charAt(i) != '9')
					cnt++;
			}
			System.out.println(9 * str.length() - cnt);
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
int main()
{
    int a,b,x,c;
    cin>>a>>b;
    c=a-b;
    if(c%2==0)
    {
        a=a+b;
        x=a/2;
        cout<<x;
    }
    else
    {
        a=a+b;
        x=a/2;
        x++;
        cout<<x;
    }
	return 0;
}


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

using namespace std;

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

  vector<string> in(n);
  for (int i=0; i < n; ++i)
    cin >> in[i];

  auto f = [&](int i, int j)->char {
    int count = 0;

    for (int r = -1; r <= 1; ++r) {
      for (int c = -1; c <= 1; ++c) {
        int rx = i+r;
        int cx = j+c;
        if ((rx>=0 && rx<n) && (cx>=0 && cx<m) && in[rx][cx] == '#') {
          count++;
        }
      }
    }

    return '0' + count;
  };

  vector<string> out(n, string(m, '#'));

  for (int i=0; i < n; ++i)
    for (int j=0; j < m; ++j)
      if (in[i][j] == '.')
        out[i][j] = f(i, j);

  for (auto s : out)
    cout << s << '\n';
}


Measured memory_bytes: 256