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

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

int main() {
    int n, x, y; cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n,0);
    rep(i,n) rng(j,i+1,n) {
        int len = j - i;
        len = min(len, abs(x-i)+1+abs(j-y));
        len = min(len, abs(y-i)+1+abs(j-x));
        ans[len]++;
    }
    rep(i,n-1) cout << ans[i+1] << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(5):
    a.append(int(input()))

m = min(a)
mi = a.index(m)
res = 0
if n%m==0:
    res += n//m
    res += 4
else:
    res += n//m
    res += 1
    res += 4
print(res)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll dfs(ll k,ll n,ll bits){
      if(k > n) return 0;
      ll ret = bits == 7 ? 1 : 0;
      for(int i = 0;i < 3;i++){
            ret += dfs(k * 10 + vector<int>{3,5,7}[i],n,1 << i | bits);

      }
      return ret;
}

int main(){
      ll n;
      cin >> n;
      cout << dfs(0,n,0) << endl;
      return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a = h1 * 60 + m1;
  int b = h2 * 60 + m2;
  cout << b - a - k << endl;
}


Measured memory_bytes: 3652
n = int(input())
d = []
for _ in range(n):
    s,t = input().split()
    tt = int(t)
    d.append([s,tt])
x = input()
ans = 0
flag = False
for a in d:
    if flag:
        ans += a[1]
    elif a[0] == x:
        flag = True
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

//Board Arrangements for Concentration Games
public class Main{

	int[][] r;
	int c;
	int[] p;
	
	void dfs(int k){
		if(k==8){
			boolean[][] a = new boolean[4][4];
			k = 0;
			boolean f = true;
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(a[i][j])continue;
					a[i][j] = true;
					int ni = i+r[p[k]][0];
					int nj = j+r[p[k]][1];
					if(0<=ni&&ni<4&&0<=nj&&nj<4&&!a[ni][nj]){
						a[ni][nj] = true;
						k++;
					}
					else {
						f = false;break;
					}
				}
			}
			if(f)c++;
			return;
		}
		for(int i=0;i<4;i++){
			p[k] = i;
			dfs(k+1);
		}
	}
	
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x = sc.nextInt();
			if(x>4)break;
			int y = sc.nextInt();
			r = new int[4][2];
			p = new int[8];
			r[0][0] = y;
			r[0][1] = x;
			for(int i=1;i<4;i++)for(int j=1;j>=0;j--)r[i][j]=sc.nextInt();
			c = 0;
			dfs(0);
			System.out.println(c);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <vector>
using namespace std;

int main()
{
	int n,m,k;
	scanf ("%d %d %d",&n,&m,&k);

	vector<int> room; int l = n;
	for (int i=0;i<m-1;i++) room.push_back(1), l--; room.push_back(k); l -= k;

	if (l < 0){ printf ("-1"); return 0; }
	for (int i=m-2;i>=0;i--) while (room[i] < k && l > 0) room[i]++, l--;
	if (l > 0){ printf ("-1"); return 0; }

	for (int i=0,s=0;i<m;i++){
		s += room[i];
		for (int j=0;j<room[i];j++) printf ("%d ",s-j);
	}

	return 0;
}

Measured memory_bytes: 3184
N = int(input())
A = [int(n) for n in input().split(' ')]

count_A = [0]*N
for a in A:
    count_A[a-1] += 1

ret = 0
for ca in count_A:
    if ca > 0:
        ret += int((ca * (ca - 1)) / 2)

for a in A:
    ca = count_A[a-1]
    print(ret-ca+1)

Measured memory_bytes: 26140
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       s:Chars,
    }

    if s[0] == 'R' && s[1] == 'R' && s[2] == 'R' {
        echo!(3);
    } else if s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R' {
        echo!(2);
    } else if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
        echo!(1);
    } else {
        echo!(0);
    }
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
string a,b,c;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b>>c;
	cout<<(a[sz(a)-1]==b[0]&&b[sz(b)-1]==c[0]?"YES":"NO");
	re 0;
}

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

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200005
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];
PLL fxx[MV];

ll bs2(ll st, ll en, ll xt)
{
	ll lo = st;
	ll hi = en;
	while(lo < hi)
	{
		ll mid = lo + (hi - lo + 1)/2;
		if(fxx[mid].ff > xt)
		hi = mid - 1;
		else lo = mid;	
	}
	return lo;
}

void solve(int T)
{
	ll n,d,a;
	cin>>n>>d>>a;
	for(ll i=1;i<=n;i++)
	cin>>fxx[i].ff>>fxx[i].ss;
	sort(fxx+1, fxx+n+1);
	ll bomb = 0;
	for(ll i=1;i<=n;i++)
	{
		ar[i] += ar[i-1];
		if(fxx[i].ss + ar[i] > 0)
		{
			ll ld = bs2(i, n, fxx[i].ff + 2*d);
			bomb += ((fxx[i].ss + ar[i] + a - 1)/a);
			ll dm = ((fxx[i].ss + ar[i] + a - 1)/a)*a;
			ar[i] -= dm;
			ar[ld+1] += dm;
		}	
	}
	cout<<bomb<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,m,a[N][N];
int ans[N*N][4],cnt;
int tmp[N],k,mp[N];
struct data {
	int x,y;
	bool operator < (const data &a) const 
	{
		if(x!=a.x) return x<a.x;
		return (y<a.y)^(mp[x]&1);
	}
}p[N*N];
void fun(int x,int y,int xx,int yy) {
	if(x==xx) {
		while(y<yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=++y;
		while(y>yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=--y;
	}
	else {
		if((mp[x]&1)^(y<yy)) {
			while(y<yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=++y;
			while(y>yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=--y;
			while(x<xx) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=++x,ans[cnt][3]=y;
		}
		else {
			while(x<xx) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=++x,ans[cnt][3]=y;
			while(y<yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=++y;
			while(y>yy) ans[++cnt][0]=x,ans[cnt][1]=y,ans[cnt][2]=x,ans[cnt][3]=--y;
		}
	}
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		bool x=0;
		for(int j=1;j<=m;j++)
			scanf("%d",a[i]+j),a[i][j]&=1,x|=a[i][j];
		if(x) tmp[++k]=i;
	}
	sort(tmp+1,tmp+k+1);
	for(int i=1;i<=k;i++) mp[tmp[i]]=i;
	k=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		if(a[i][j]) p[++k].x=i,p[k].y=j;
	sort(p+1,p+k+1);
	for(int i=1;i<k;i+=2)
		fun(p[i].x,p[i].y,p[i+1].x,p[i+1].y);
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
	return 0;
}

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

int main (){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a<=b&&b<=c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c&&c<=b){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<=a&&a<=c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c&&c<=a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<=a&&a<=b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b&&b<=a){
		cout<<c<<" "<<b<<" "<<a<<endl;
	}
	


	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define dg(x) cerr << #x << " = " << x <<endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fore(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main(){
#ifdef LOCAL
    //freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
    #define endl '\n'
#endif
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
//#define REP(i,a,b) for(int i=a;i<=b;i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
long long MOD=1e9+7;

int main()
{	
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,c,d,i,j,t,n,m,k,num;
	double q;
	cin>>q;
	q=ceil(q/2);
	q=int(q);
	cout<<q;
	}


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

namespace ConsoleApp15
{
    class Class396
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine())-1;
            string ans = "";
            int count = 1 ;

            int leng = 1;
            long n = N;
            while (true)
            {
                if (n >= Math.Pow(26, leng))
                {
                    n -= (long)Math.Pow(26, leng);
                    leng++;
                }
                else break;
            }
            
            for(int i = 0; i < leng; i++)
            {
                
                long a = N / (long)Math.Pow(26, i);
                a %= 26;
                N -= (a+1)*(long)Math.Pow(26,i);
                if(N<0)N+=(long)Math.Pow(26,i+1);
                //a = (a + 25) % 26;

                ans += (char)('a' + a);
            }
            /*
            for (int i = leng - 1; i >= 0; i--)
            {
                long a = (N / (long)(Math.Pow(26, i)));
                if (i >= 1) a-=1;
                N %= (long)Math.Pow(26,i);
                
                ans += (char)('a' + a);
            }
            */
            ans = string.Join("", ans.Reverse());
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28616
import collections

n = int(input())
s = [input() for _ in range(n)]

c = collections.Counter(s)

b, most = c.most_common(1)[0]

ans = []
for i,j in c.most_common():
  if j != most:
    break
  ans.append(i)
for ans_v in sorted(ans):
  print(ans_v)

Measured memory_bytes: 45804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << min({a+b,b+c,c+a}) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long n;
	long long a=-1000000,b=10000000,c=0;
	cin>>n;
	for(long long i=0;i<n;i++){
		int in;
		cin>>in;
		if(in>=a){
			a=in;
		}else{
		}
		if(in<=b){
			b=in;
		}else{
		}
		c=c+in;
	}
	cout<<b<<" "<<a<<" "<<c<<endl;
}





Measured memory_bytes: 3092
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int r, D, x;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; ++i)
	{
		x = r * x - D;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
G = [list(map(int,input().split())) for k in range(N)]

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

G = sorted(G, key=lambda x: -x[2])
for Cx in range(101):
    for Cy in range(101):
        f = 1
        H = G[0][2] + abs(Cx-G[0][0]) + abs(Cy-G[0][1])
        for k in range(1,N):
            if max(0,H-abs(G[k][0]-Cx)-abs(G[k][1]-Cy)) != G[k][2]:
                f = 0
        if f:
            print(Cx,Cy,H)



Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		DecimalFormat df = new DecimalFormat("0.000");
		String str = br.readLine();
		while (str != null) {
			String[] datasetstr = str.split(" ", 6);
			int a = Integer.parseInt(datasetstr[0]);
			int b = Integer.parseInt(datasetstr[1]);
			int c = Integer.parseInt(datasetstr[2]);
			int d = Integer.parseInt(datasetstr[3]);
			int e = Integer.parseInt(datasetstr[4]);
			int f = Integer.parseInt(datasetstr[5]);
			double x = (double) (e * c - b * f) / (a * e - b * d);
			double y = (double) (a * f - c * d) / (a * e - b * d);
			Double X = new Double(x);
			Double Y = new Double(y);
			Boolean isNegativezeroX = X.equals(-0.0);
			Boolean isNegativezeroY = Y.equals(-0.0);
			if (isNegativezeroX) {
				x = -x;
			}
			if (isNegativezeroY) {
				y = -y;
			}
			System.out.println(df.format(x) + " " + df.format(y));
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 25760
#include <iostream>
#define rep(i,j,k) for(int i=j;(i)<(k);(i)++)
using namespace std;
#define mod 1000000007
#define mmax 1000000
typedef long long ll;
ll f[mmax], rf[mmax];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    rep(i, 1, mmax) f[i] = (f[i - 1] * i) % mod;
    rep(i, 0, mmax) rf[i] = inv(f[i]);
}
//------------------------------------------------------------------
ll C(int n, int k) {
    init();
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!
    
    ll bc = (b * c) % mod;
    
    return (a * bc) % mod;
}
int main(void){
    int x,y;
    cin >> x >> y;
    if((x+y)%3 != 0){
        printf("0\n");
    }else{
        int layer = (x+y)/3;
        int left = x-layer;
        if (left < 0 || layer - left < 0) {
            cout << 0;
            return 0;
        }
        //printf("%d %d\n",layer,left);
        printf("%lld\n",C(layer,left));
        //printf("%lld\n",C(a+b,min(a,b)));
        
    }
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define MAXN 1000010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll fac[MAXN], invfac[MAXN], ans;
int N;
inline ll fpow(const ll& x, ll c)
{
	register ll res = 1, t = x;
	while (c)
	{
		if (c & 1) res = res * t % MOD;
		t = t * t % MOD;
		c >>= 1;
	}
	return res;
}
inline ll C(const int& n, const int& m)
{
	if (n < m) return 0;
	return fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}
inline ll W(const int& k)
{
	int x = N - 2 - k;
	int y = k - x;
	if (x < 0 || y < 0) return 0;
	return fac[k] * invfac[y] % MOD * invfac[x] % MOD;
}
int main()
{
	scanf("%d", &N);
	if (N == 2)
	{
		puts("1");
		return 0;
	}
	fac[0] = invfac[0] = 1;
	for (register int i = 1; i <= N; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	invfac[N] = fpow(fac[N], MOD - 2);
	for (register int i = N - 1; i >= 1; --i)
		invfac[i] = invfac[i + 1] * (i + 1) % MOD;
	ans += fac[N - 1];
	for (register int i = 1; i < N - 1; ++i)
		ans += (C(N - 2, i) + C(N - 2, i - 1) + MOD - W(i - 1))* fac[i] % MOD * fac[N - 1 - i] % MOD, ans %= MOD;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 15872
import copy
H, W, K = map(int, input().split())
A = [list(input()) for i in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        s1 = format(i, "0%ib" % H)
        s2 = format(j, "0%ib" % W)
        C = copy.deepcopy(A)
        for _i in range(H):
            if s1[_i] == "1":
                for x in range(W):
                    C[_i][x] = "r"
        for _j in range(W):
            if s2[_j] == "1":
                for y in range(H):
                    C[y][_j] = "r"
        cnt = 0
        for ii in range(H):
            for jj in range(W):
                cnt += int(C[ii][jj] == "#")
        ans += int(cnt == K)
print(ans)

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

const int MOD = (int)1e9+7;

int main(){
  long long N;
  cin >> N;

  N++;
  int ans=0;
  while(N>9){
    ans+=9;
    N/=10;
  }
  ans+=N-1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (i + 1 == k)  {
            cout << (char)(s[i] + 32);
        } else {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#重み付きUnion-Findによる実装
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        px = find(par[x])
        wei[x] += wei[par[x]]
        par[x] = px
        return px

#xの根から距離
def weight(x):
    find(x)
    return wei[x]


#w[y]=w[x]+wとなるようにxとyを併合
def unite(x,y,w):
    w += wei[x]-wei[y]
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
            w = -w
        par[x] += par[y]
        par[y] = x
        wei[y] = w
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#x,yが同じ集合に属するときのwei[y]-wei[x]
def diff(x,y):
    return weight(y)-weight(x)

N,M = map(int,readline().split())
#0-index
par = [-1]*N
wei = [0]*N
for _ in range(M):
    l,r,d = map(int,readline().split())
    l,r = l-1,r-1
    if same(l,r):
        if d != diff(l,r):
            print('No')
            exit()
    else:
        unite(l,r,d)
print('Yes')

Measured memory_bytes: 14832
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>

#define MAXN 100005

using namespace std;

template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
       c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}


int N,A,B;
char s[MAXN];
void Solve() {
    read(N);read(A);read(B);
    scanf("%s",s + 1);
    int r = 1,all = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(s[i] == 'a') {
            if(all < A + B) {puts("Yes");++all;}
            else puts("No");
        }
        else if(s[i] == 'b') {
            if(all < A + B && r <= B) {puts("Yes");++all;++r;}
            else puts("No");
        }
        else {
            puts("No");
        }
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 3812
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  map<string,int> ma;
  string s;
  V<string> ans(0);
  int mx=0;
  rep(i,0,n){
    cin>>s;
    ma[s]++;
    chmax(mx,ma[s]);
  }

  for(auto&& i:ma){
    if(i.sc==mx)ans.eb(i.fs);
  }
  sort(all(ans));
  rep(i,0,siz(ans)){
    cout<<ans[i]<<ENDL;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 25584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/


int main() {
	int N;
	cin >> N;
	vector<double>X(N);
	vector<double>Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}
	vector<double>x(N);
	vector<double>y(N);
	double all = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			x[j] = X[j];
			y[j] = Y[j];
		}
		x[0] = X[i];
		x[i] = X[0];
		y[0] = Y[i];
		y[i] = Y[0];
		for (int l = 0; l < N; l++) {
			//cout << x[l] << ' ' << y[l] << endl;
		}
		for (int k = 0; k < N; k++) {
			all += sqrt(pow(x[0] - x[k], 2) + pow(y[0] - y[k], 2));
			//cout << sqrt(pow(x[0] - x[k], 2) + pow(y[0] - y[k], 2)) << endl;
			//cout << all << endl;
		}
	}
	double kai = 1;
	for (int i = 1; i < N; i++) {
		kai *= i;
	}
	//cout << all << endl;
	//cout << kai << endl;
	cout <<setprecision(20)<< all * kai/(kai*N) << endl;
}

Measured memory_bytes: 256
/* -----KAUN_MEET--------*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int mod = 1000000007;
#define P get<0>
#define D get<1>
#define T get<2>
#define C get<3>
#define PB push_back
#define MP make_pair
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define F first
#define S second
#define gcd __gcd
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

void __print(int x)
{
    cerr << x;
}
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename Th, typename V>
void __print(const pair<Th, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename Th>
void __print(const Th &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename Th, typename... V>
void _print(Th t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
void binary_rock()
{
    string c,d;
    cin>>c>>d;

    string a,b;
    a.PB('.');
    b.PB('.');

    int i,j,k,l;
    
    
    // cin>>a>>b;
    int n,m;
    n=c.size();
    m=d.size();
    
    for(i=0;i<n;i++){
        a.PB(c[i]);
    }
    for(i=0;i<m;i++){
        b.PB(d[i]);
    }
    
    
    int ans[n+1][m+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++)
        ans[i][j]=0;
    }



    for(i=1;i<=n;i++){

        for(j=1;j<=m;j++){
            ans[i][j]=max(ans[i-1][j],ans[i][j-1]);

            if(a[i]==b[j]){
                ans[i][j]=max(ans[i][j],ans[i-1][j-1]+1);
            }
        }
    }
    // for(i=0;i<=n;i++){
    //     for(j=0;j<=m;j++)
    //     cout<<ans[i][j]<<" ";
    //     cout<<endl;
    // }

    i=n;
    j=m;
    string pri="";
    while(pri.size()!=ans[n][m]){

        if(ans[i][j]==ans[i-1][j]) i-=1;
        else if(ans[i][j]==ans[i][j-1]) j-=1;
        else{
            pri.PB(a[i]);
            i--;
            j--;
        }

    }
    reverse(pri.begin(),pri.end());
    cout<<pri<<endl;

}

signed main()
{
    fastio
        clock_t t1 = clock();

    int t = 1;
    // cin >> t;
    while (t--)
    {
        binary_rock();
    }

    clock_t t2 = clock();
    // cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;
    // cout << CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int H, N;
    cin >> H >> N;
    int sum = 0;
    rep(i, 0, N){
        int A;
        cin >> A;
        sum += A;
    }
    if (sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    int n;cin>>n;
  	string s="ACL";
  	for(int i=1;i<=n;i++)
    cout<<s;
}
int32_t main()
{
	rapido;
	int t;
	//cin>>t;
	 t=1;
	while(t--)
	solve();
	return 0;
}


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

int main(void){
	string s;
	cin >> s;
	char comp = 'a';
	for (int i = 0; i < 26; ++i){
		if (s.find(char(comp + i)) == -1){
			cout << char(comp + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const ll maxn = 55;
int arr[4];
bool visited[105][105][105];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> arr[0] >> arr[1] >> arr[2];
    queue<int> q;
    q.push(arr[0]);
    q.push(arr[1]);
    q.push(arr[2]);
    q.push(0);
    memset(visited, false, sizeof visited);
    int a, b, c, cekor;
    int tmpA, tmpB, tmpC;
    while(!q.empty()){
        a = q.front();
        q.pop();
        b = q.front();
        q.pop();
        c = q.front();
        q.pop();
        cekor = q.front();
        q.pop();
        if(a == b && a == c && b == c){
            cout << cekor << endl;
            return 0;
        }
        if(visited[a][b][c])continue;
        visited[a][b][c] = true;
        q.push(a + 2);
        q.push(b);
        q.push(c);
        q.push(cekor + 1);
        
        q.push(a);
        q.push(b + 2);
        q.push(c);
        q.push(cekor + 1);
        
        q.push(a);
        q.push(b);
        q.push(c + 2);
        q.push(cekor + 1);
        
        for(int mask = 0; mask < (1 << 3); mask ++){
            tmpA = a;
            tmpB = b;
            tmpC = c;
            if(__builtin_popcount(mask) != 2){
                continue;
            }
            for(int i = 0; i < 3; i ++){
                if(mask & (1 << i)){
                    if(i == 0){
                        tmpA ++;
                    }
                    if(i == 1){
                        tmpB ++;
                    }
                    if(i == 2){
                        tmpC ++;
                    }
                }
            }
            q.push(tmpA);
            q.push(tmpB);
            q.push(tmpC);
            q.push(cekor  +1);
        }
        
    }
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pairll=pair<ll,ll>;
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	char ch; cin >> ch;
	cout << (char)(ch+1) << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	fmt.Println(a * b)
}


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

int main()
{
    char a[2][3],b[2][3];
    int i,j,flag=0;
    for(i=0; i<2; i++)
    {
        scanf("%s",a[i]);
    }
    for(i=1; i>=0; i--)
    {
        for(j=2; j>=0; j--)
        {
            b[1-i][2-j]=a[i][j];
        }
    }
    for(i=0; i<2; i++)
    {
        for(j=0; j<3; j++)
        {
            if(b[i][j]!=a[i][j])
            {
                flag=1;
            }
        }
    }
    if(flag==1)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];

    lint sum = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) sum += A[i];
        if (i % 2 == 1) sum -= A[i];
    }

    for (int i = 0; i < N; i++) {
        cout << sum << endl;

        sum -= A[i];
        sum *= -1;
        sum += A[i];
    }

    return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;
int main() {
	long long k, n,sum=0,tmp;
	long long ans=0;
	vector<long> v;

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(),v.end());

	for (int i = 0; i < n - k;i++) {
		ans += v[i];
	}
	
	cout << ans;

	return 0;
}

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

int main()
{
    int n,a=0,b=0,c=0,d=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        string s; cin>>s;
        if(s=="AC") a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
const ll inf=5*(ll)1e18;
int x[100],y[100];
map<int,int> mpx,mpy;
           
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    mpx[x[i]]=y[i];
    mpy[y[i]]=x[i];
  }
  sort(x,x+n);
  sort(y,y+n);
  ll ans=inf;
  for(int r=0;r<n;r++){
    for(int l=0;l<r;l++){
      if(r-l+1<m)continue;
      vector<ll> vv;
      for(int i=l;i<=r;i++){
        vv.push_back(mpx[x[i]]);
      }
      sort(vv.begin(),vv.end());
      ll mindy=inf;
      for(int i=0;i<(int)vv.size();i++){
        if(i+m-1>=(int)vv.size())break;
        mindy=min(mindy,vv[i+m-1]-vv[i]);
      }
      ans=min(ans,mindy*(x[r]-x[l]));
      //cout<<ans<<endl;
    }
  }
  for(int r=0;r<n;r++){
    for(int l=0;l<r;l++){
      if(r-l+1<m)continue;
      vector<ll> vv;
      for(int i=l;i<=r;i++){         
        vv.push_back(mpy[y[i]]);
      }
      sort(vv.begin(),vv.end());
      ll mindx=inf;
      for(int i=0;i<(int)vv.size();i++){
        if(i+m-1>=(int)vv.size())break;
        mindx=min(mindx,vv[i+m-1]-vv[i]);
      }
      ans=min(ans,mindx*(y[r]-y[l]));
    }
  }
  cout<<ans<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using namespace std;

int main(void) {
    long a;
    double b;
    long double ans;
    cin >> a >> b;
    ans = (long double) ((long)(a * (long)(b * 100 + 0.5))) / 100;
    //cout << "a = " << a << " b = " << b << " ans = " << ans << endl;
    cout << (long)ans << endl;
    return 0;
}

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

void count(vector<int> &ans, int begin, int end, int loop)
{
    for (int i = begin; i < end; i++)
    {
        if ((abs(loop - i) % 2) == 0)
        {
            ans[loop]++;
        }
        else
        {
            ans[loop - 1]++;
        }
    }
}

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

    vector<int> ans(S.size(), 0);
    char current_directrion = 'R';
    int start_idx = 0;
    int current_idx = 1;
    int loop_idx;
    for (; current_idx < S.size(); current_idx++)
    {
        if (current_directrion != S[current_idx])
        {
            if (current_directrion == 'R')
            {
                current_directrion = 'L';
                loop_idx = current_idx;
            }
            else if (current_directrion == 'L')
            {
                count(ans, start_idx, current_idx, loop_idx);
                current_directrion = 'R';
                start_idx = current_idx;
            }
        }
    }
    count(ans, start_idx, current_idx, loop_idx);

    for (int a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())

p = 0

t = 0
while 2**t < k:
    t += 1

for i in range(1, n+1):
    j = 0
    while i* 2**j < k:
        j += 1
    p += 2**(t-j)

p = p / n / 2**t

print(p)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll c_to_i(char tmp){
  return (tmp - 'a');
}

int main(){

  ll N;
  string S;
  IN(N);
  IN(S);

  vll X(32, 0);
  vll Y(32, 0);
  REP(i,N) Y[c_to_i(S[i])]++;
  ll ans = 0;
  REP(i,N){
    X[c_to_i(S[i])]++;
    Y[c_to_i(S[i])]--;
    ll tmp=0;
    REP(j,32){
      if(X[j]>0 && Y[j]>0) tmp++;
    }
    ans = max(ans, tmp);
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,ans=0;
  cin>>a>>b;
  for(int i=0;i<=a;i++)
    for(int k=0;k<=a;k++)
      if(a>=b-i-k&&0<=b-k-i)
      {
          ans++;
          continue;
      }
  cout<<ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 105
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;


class Edge {
public:
    ll s, t, w;
    bool p;
    Edge(ll s, ll t, ll w, bool p=false): s(s), t(t), w(w), p(p) {}
};

ll N, M;
ll dist[100][100];
vector<Edge> edges;

int main(void) {
    cin >> N >> M;
    ll i, j, k;
    ll a, b, c;
    ll s;
    for(i=0; i<N; i++) {
        for(j=0; j<N; j++) {
            dist[i][j]=(i==j ? 0 : INF);
        }
    }
    
    for(i=0; i<M; i++) {
        cin >> a >> b >> c;
        a--; b--;
        edges.push_back(Edge(a, b, c));
        dist[a][b]=dist[b][a]=c;
    }
    
    for(k=0; k<N; k++) {
        for(i=0; i<N; i++) {
            for(j=0; j<N; j++) {
                dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
    
    for(s=0; s<N; s++) {
        for(i=0; i<M; i++) {
            if(dist[s][edges[i].t]==dist[s][edges[i].s]+edges[i].w)
                edges[i].p=true;
        }
    }
    
    ll ans=0;
    
    for(i=0; i<edges.size(); i++) {
        if(!edges[i].p) ans++;
    }
    
    prin(ans);
    
}

Measured memory_bytes: 384
h,w = map(int,input().split())
s = [input() for _ in range(h)]

dp = [[10**10] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        s1 = s[i][j]
        if i == 0 and j == 0:
            if s1 == '.':
                dp[i][j] = 0
            else:
                dp[i][j] = 1
        elif i == 0:
            if s1 == '#' and s[i][j-1] == '.':
                dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = dp[i][j-1]
        elif j == 0:
            if s1 == '#' and s[i-1][j] == '.':
                dp[i][j] = dp[i-1][j] + 1
            else:
                dp[i][j] = dp[i-1][j]
        else:
            if s1 == '#' and s[i][j-1] == '.':
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])
            if s1 == '#' and s[i-1][j] == '.':
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])

print(dp[-1][-1])


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 500001

int A[N], n;

int par(int i){ return i / 2; }
int lef(int i){ return i * 2; }
int rig(int i){ return i * 2 + 1; }

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

	for (int i = 1; i <= n; ++i) {
		cout << "node " << i << ": " << "key = " << A[i] << ", ";
		int p = par(i);
		int l = lef(i);
		int r = rig(i);
		if (p >= 1) cout << "parent key = " << A[p] << ", ";
		if (l <= n) cout << "left key = " << A[l] << ", ";
		if (r <= n) cout << "right key = " << A[r] << ", ";
		cout << endl;
	}
}

//node 1: key = 7, left key = 8, right key = 1,
//node 2 : key = 8, parent key = 7, left key = 2, right key = 3,
//node 3 : key = 1, parent key = 7,
//node 4 : key = 2, parent key = 8,
//node 5 : key = 3, parent key = 8,

Measured memory_bytes: 3068
def get_t(T, x):
    return (T - x*0.006)

N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())

ans = (-1, 1000000)

for i, h in enumerate(H):
    if abs(ans[1] - A) > abs(get_t(T, h) - A):
        ans = (i + 1, get_t(T, h))

print(ans[0])


Measured memory_bytes: 3060