akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  string s,t;cin>>s>>t;
  //vec v(N);
  cout<<t<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let n: i32 = t.take();
    let k: i32 = t.take();
    let mut h: Vec<i32> = Vec::new();
    for _i in 0 .. n {
        h.push( t.take() );
    }
    println!( "{}", problem( k, h ));
}

fn problem( k:i32, h:Vec<i32> ) -> i32 {
    let num: Vec<i32> = h.iter().filter( |it| { **it >= k } ).cloned().collect();
    num.len() as i32
}


#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test1() {
        let result = problem( 5 );
        assert_eq!(result,vec![3,6,1]);
    }
}


struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


Measured memory_bytes: 10492
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	
	int ans = 1;
	int pmin = p[0];
	
	for (int i = 1; i < n; i++) {
		if (p[i] <= pmin) {
			ans++;
		}
		pmin = min(pmin, p[i]);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1024
//TAKOYAKI FESTIVAL 2019
#include <iostream>
using namespace std;
int main () {

		
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) {
				ans += (a[i] * a[j]);
			}
		}
	}
	cout << ans / 2;

}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    
    ss s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

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

int f(int a, int b){
  int mx = max(a, b), mn = min(a, b);
  while(mn>0){
  	int r = mx%mn;
  	mx = mn; mn = r;
  }
  return mx;
}

int main(){
  int k; cin >> k;
  int ans = 0;
  for(int i = 1; i <= k; i++){
  for(int j = 1; j <= k; j++){
  for(int l = 1; l <= k; l++){
  	int gcd = f(i, j);
  	gcd = f(gcd, l);
  	ans += gcd;
  }
  }
  }
  
  cout << ans << endl;
  //cout << f(1, 12) << endl;
}

Measured memory_bytes: 3592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dp[1<<8][4][1<<8];
int dfs(int n, int num, int prv){
  if(num == 4){
	return (n==0? 1: 0);
  }
  if(n < (1<<8) && dp[n][num][prv] >= 0) return dp[n][num][prv];

  int sum = 0;
  for(int i=prv;i*i<=n;++i){
	sum += dfs(n-i*i, num+1, i);
  }

  if(n < (1<<8))
	dp[n][num][prv] = sum;
  return sum;
}

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

  int N;
  fill((int*)dp, (int*)dp+(1<<16)*4, -1);
  while(cin>>N,N){
	cout << dfs(N, 0, 0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2212
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



int main(){
    int n, W; cin >> n >> W;
    VI w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    //i番目(1-order)まで, 　価値j以上 で重さ最小値
    vector<VLL> dp(n+1, VLL(100001, 2*INF));
    dp[0][0] = 0;
    FORS(i, 1, n){
        REP(j, 100001){
            if(j >= v[i-1])
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);

            else dp[i][j] = dp[i-1][j];
        }
    }
    RFOR(j, 100000, 0){
        if(dp[n][j] <= W){
            cout << j << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
int s[210000];
int main() {
	REP(i, 210000) s[i] = INF;
	int n, m ,k = 0,ans = 0;
	cin >> n >> m;
	REP(i, n) {
		int a;
		cin >> a;
		if (s[a] == INF) s[a] = 1;
		else s[a]++;
	}
	sort(s, s + 202020);
	REP(i, 210000) {
		if (s[i] == INF) break;
		else k++;
	}
	REP(i, k - m) ans += s[i];
	cout << ans << endl;
}



Measured memory_bytes: 1024
/*
                   ,.ood888888888888boo.,
              .od888P^""            ""^Y888bo.
          .od8P''   ..oood88888888booo.    ``Y8bo.
       .odP'"  .ood8888888888888888888888boo.  "`Ybo.
     .d8'   od8'd888888888f`8888't888888888b`8bo   `Yb.
    d8'  od8^   8888888888[  `'  ]8888888888   ^8bo  `8b
  .8P  d88'     8888888888P      Y8888888888     `88b  Y8.
 d8' .d8'       `Y88888888'      `88888888P'       `8b. `8b
.8P .88P            """"            """"            Y88. Y8.
88  888                                              888  88
88  888                                              888  88
88  888.        ..                        ..        .888  88
`8b `88b,     d8888b.od8bo.      .od8bo.d8888b     ,d88' d8'
 Y8. `Y88.    8888888888888b    d8888888888888    .88P' .8P
  `8b  Y88b.  `88888888888888  88888888888888'  .d88P  d8'
    Y8.  ^Y88bod8888888888888..8888888888888bod88P^  .8P
     `Y8.   ^Y888888888888888LS888888888888888P^   .8P'
       `^Yb.,  `^^Y8888888888888888888888P^^'  ,.dP^'
          `^Y8b..   ``^^^Y88888888P^^^'    ..d8P^'
              `^Y888bo.,            ,.od888P^'
                   "`^^Y888888888888P^^'"
*/

#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1e9+7
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	
	int n;
	cin >> n;
	string v;
	vector<string> s;
	forn(i, n){
		cin >> v;
		s.pb(v);
	}
	sort(all(s));
	vi vec(n, 1);
	int mx{1};
	int l{0};
	for(int i=1; i<n;i++){
		if(s[i]==s[i-1]){
			vec[l]+=1;
			mx=max(mx, vec[l]);
		}else{
			l=i;
		}
	}
	for(int i=0;i<n;i++){
		if(vec[i]==mx)
			cout << s[i] << endl;
	}


	return 0;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases ( n=0, 1, negatives ? )
	* do smth instead of nothing and stay organized
*/



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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(11) << sum / Factorial << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4220
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e6+5;
const int INF=0x3f3f3f3f;
int num[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    bool pairwise=true,setwise=true;
    for(int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        for(int j=2;j*j<=a;j++)
        {
            int cnt=0;
            for(;a%j==0;a/=j) cnt++;
            if(cnt) num[j]++;
        }
        if(a>1) num[a]++;
    }
    for(int i=1;i<=1000000;i++)
    {
        if(num[i]>1) pairwise=false;
        if(num[i]==n) setwise=false;
    }
    if(pairwise) puts("pairwise coprime");
    else if(setwise) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}


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

int main(){
	long h, w;
	scanf("%ld%ld", &h, &w);
	if(h == 1 || w == 1)
		printf("1\n");
	else
		printf("%ld\n", (h * w + 1) / 2);
}


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

int main() {
  string S; cin >> S;
  int n = S.size();
  ll ans = 0;
  rep(bit,(1<<n-1)){
    ll sum = 0;
    rep(i,n){
      sum *= 10;
      sum += S[i] -'0';
      if(bit & 1<<i){
        ans += sum;
        sum = 0;
      }
    }
    ans += sum;
  }

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



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;

ll fast_exp(int base, int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
}
int main(){
   int n;
   cin>>n;
   vector<ll> A(n);
   for(int i=0;i<n;i++)
    cin>>A[i];
    int N=n;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,INF));
    
    for(int L=N-1;L>=0;L--){
        for(int R=L;R<n;R++){
            if(L==R)
                dp[L][R]=0;
            else{
                ll sum=0;
                for(int i=L;i<=R;i++)
                    sum+=A[i];
                for(int k=L;k<=R-1;k++){
                    dp[L][R] = min(dp[L][R],dp[L][k]+dp[k+1][R]+sum);
                }
            }
        }
    }
    
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=n;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
    cout<<dp[0][n-1]<<endl;
    
}

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

int H, W, N;
vector<pair<int,int>> v;
vector<vector<int>> out;
int main(void) {
  cin >> H >> W;
  cin >> N;
  out = vector<vector<int>>(H, vector<int>(W));
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    v.push_back({ t, i+1 });
  }
  sort(v.begin(), v.end());
  int now = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (v[now].first == 0) now++;
      out[y][x] = v[now].second;
      v[now] = { v[now].first - 1, v[now].second };
    }
    y++;
    if (y == H) break;
    for (int x = W - 1; x >= 0; x--) {
      if (v[now].first == 0) now++;
      out[y][x] = v[now].second;
      v[now] = { v[now].first - 1, v[now].second };
    }
  }
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      cout << out[y][x] << ((x == W - 1) ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<string, int> S;
  int m = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (!S.count(s))
      S[s] = 1;
    else
      S[s]++;
    m = max(m, S[s]);
  }

  for (auto p : S) {
    if (p.second == m) cout << p.first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
import scala.io.StdIn.{readLong,readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val input = readLine.split(" ").map(_.toInt) 
        val luggages = (1 to input(0)).foldLeft(Nil: List[Long]) { (list, v) => readLong :: list}
        println(allocation(input(1), luggages.reverse))
    }
    def allocation(k: Int, wList: List[Long]): Long = {
        // 最大積載量 = capacity の場合にトラックに荷物が乗り切るかどうか
        def inCapacity(luggages: List[Long], truck: Int, capacity: Long, curr: Long): Boolean = luggages match {
            case Nil => true
            case x :: xs if (x > capacity) => false
            case x :: xs => curr + x match {
                case tmp if tmp > capacity => if (truck == 1) false else inCapacity(xs, truck - 1, capacity, x)
                case tmp => inCapacity(xs, truck, capacity, tmp)
            }
        }
        // すべての荷物が乗り切るトラックの積載量の最小値を2分木探索で探索
        def binSearch(min: Long, max: Long, currMin: Long): Long = (min + max) / 2 match {
            case median if min == max => if (median < currMin && inCapacity(wList, k, median, 0L)) median else currMin
            case median => inCapacity(wList, k, median, 0) match {
                case true => binSearch(min, median, median)
                case false => binSearch(median + 1, max, currMin)
            }
        }

        val maxCapa = 100000 * 100000
        binSearch(0L, maxCapa, maxCapa)
    }
}


Measured memory_bytes: 64724
import sys
input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N = int(input())
    a = make_divisors(N)
    a.sort()
    ans = 10
    for i in a:
        ans = min(ans, len(str(max(i, N/i))))
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())
a=[int(x) for x in input().split()]
cum_a=[]
for i in range(n):
    if i==0:cum_a.append(a[i])
    else:cum_a.append(cum_a[-1]+a[i])
ans=0
for i in range(n-1):
    ans+=a[i]*(cum_a[n-1]-cum_a[i])
    ans%=mod
     
print(ans)

Measured memory_bytes: 117116
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int r;
  int D;
  int x0;
  cin >>r>>D>>x0;
int x1=r*x0-D;
  int x2=r*x1-D;
  int x3=r*x2-D;
  int x4=r*x3-D;
  int x5=r*x4-D;
  int x6=r*x5-D;
  int x7=r*x6-D;
  int x8=r*x7-D;
  int x9=r*x8-D;
  int x10=r*x9-D;
  cout <<x1<<endl;
  cout <<x2<< endl;
  cout <<x3<< endl;
  cout <<x4<< endl;
  cout <<x5<< endl;
  cout <<x6<< endl;
  cout <<x7<< endl;
  cout <<x8<< endl;
  cout <<x9<< endl;
  cout <<x10<< endl;
}

Measured memory_bytes: 256
while line = gets do
	while line !~ /th(e|is|at)/
		line = line.unpack("C*").map{|n|
			if n >= 97 and n <= 122 then
				(n-97 + 1)%26+97
			else
				n
			end
		}.pack("C*")
	end
	puts line
end

Measured memory_bytes: 8680
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[100000];

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  scanf("%s", s);
  int l = strlen(s);
  s[l - 8] = 0;
  printf("%s\n", s);


  return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2000000007
#define infll 2e18
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;


int main(){
    ll num;
    cin>>num;
    ll cpy = num;
    ll sum = 0;
    while(num){
        sum += (num % 10LL);
        num /= 10LL;
    }
    if(cpy % sum){
        puts("No");
    }else{
        puts("Yes");
    }
}




Measured memory_bytes: 256
n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()] 
e = [[int(i) for i in input().split()] for i in range(m)]

a.sort()
e.sort(key=lambda x: x[1], reverse=True)
c = 0
arr = []
for i, el in enumerate(e):
  for j in range(el[0]):
    #print(c,n)
    if (c < n):
        arr.append(el[1])
        c += 1
    else:
        break
  if (c >= n):
    break
retval = 0
#print(arr)
for i in range(c):
  if (a[i] < arr[i]):
    a[i] = arr[i]
    #print(a[i],arr[i])
  else:
    break
  #print(a)
print(sum(a))


Measured memory_bytes: 26988
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=109;
int map1[maxn][maxn];
int flag[maxn];
int vis[maxn];
int c[maxn];

void spfa(int u,int n){
    queue<int>q;
    memset(flag,0,sizeof(flag));
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++)
        vis[i]=inf;
    vis[0]=0;c[0]=1,flag[0]=1;
    q.push(0);
    while(!q.empty()){
        int now=q.front();
        q.pop();
        flag[now]=0;
        for(int i=0;i<n;i++){
            if(vis[i]>vis[now]+map1[now][i]){
                vis[i]=vis[now]+map1[now][i];
                if(!flag[i]){
                    flag[i]=1;
                    q.push(i);
                }

            }
        }
    }
}

int main(){
    int n,u,v,w,k;
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(i==j)
                    map1[i][j]=0;
                else
                    map1[i][j]=inf;
        for(int i=0;i<n;i++){
            scanf("%d%d",&u,&k);
            for(int j=0;j<k;j++){
                scanf("%d%d",&v,&w);
                if(map1[u][v]>w)
                    map1[u][v]=w;
            }
        }
        spfa(0,n);
        for(int i=0;i<n;i++)
            printf("%d %d\n",i,vis[i]);
    }
    return 0;
}





Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// // vector入力
// template <typename T>
// istream &operator>>(istream &is, vector<T> &vec)
// {
//   for (T &x : vec)
//     is >> x;
//   return is;
// }
// // vector出力
// template <typename T>
// ostream &operator<<(ostream &os, vector<T> &vec)
// {
//   // os << '{';
//   for (int i = 0; i < vec.size(); i++)
//   {
//     os << vec[i] << (i + 1 == vec.size() ? "" : ' ');
//   }
//   // os << '}';
//   return os;
// }

int main()
{
  ll k, s, ans = 0LL;
  cin >> k >> s;
  rep(i, k)
  {
    rep(j, k)
    {
      ll z = s - (i + j);
      if (0 <= z && z <= k)
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <string>

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

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

struct UnionFindTree {
    vector<int> par, rank;
    UnionFindTree(int n) : par(n , -1), rank(n, 0) { }
    int find(int x) {
        if (par[x] == -1) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

/*
    verified
    https://atcoder.jp/contests/abc120/tasks/abc120_d
*/
int main() {
    int n, q; cin >> n >> q;
    UnionFindTree union_find_tree(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) union_find_tree.unite(x, y);
        else cout << union_find_tree.same(x, y) << endl;
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //uniform_int_distribution<int>(l, r)(rng);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i == n - 1 && a[i] < x) {
            break;
        }
        if (a[i] <= x) {
            x -= a[i];
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int cnt[1001][1000]={0};
int main(void)
{
	int len,llen,ccnt,sum,i,j;
	char t[1001],b[1001];
	scanf("%s %s",t,b);
	len=strlen(t);
	llen=strlen(b);
	for(i=len-1;i>=0;i--){
		if(t[i]==b[llen-1]){
			cnt[llen-1][i]++;
		}
	}
	for(i=llen-2;i>=0;i--){
		ccnt=0;
		for(j=len-1;j>=0;j--){
			if(b[i]==t[j]){
				cnt[i][j]=ccnt;
			}
			ccnt+=cnt[i+1][j];
			ccnt=ccnt%1000000007;
		}
	}
	for(i=len-1;i>=0;i--){
		sum+=cnt[0][i];
		sum=sum%1000000007;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 6588
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, q = LI()
    S = SI()

    Q = [LS() for _ in range(q)]

    def left_out(i):
        if i < 0: return True
        if i >= n: return False
        for t, d in Q:
            if t != S[i]: continue
            if d == 'L':
                i -= 1
                if i < 0: return True
            else:
                i += 1
                if i >= n: return False

        return False

    def right_out(i):
        if i < 0: return False
        if i >= n: return True
        for t, d in Q:
            if t != S[i]: continue
            if d == 'L':
                i -= 1
                if i < 0: return False
            else:
                i += 1
                if i >= n: return True

        return False

    # 左へ落ちるロボット
    l_ok, l_ng = -1, n
    while abs(l_ok - l_ng) > 1:
        mid = (l_ok + l_ng) // 2
        if left_out(mid):
            l_ok = mid
        else:
            l_ng = mid

    # 右へ落ちるロボット
    r_ok, r_ng = n, -1
    while abs(r_ok - r_ng) > 1:
        mid = (r_ok + r_ng) // 2
        if right_out(mid):
            r_ok = mid
        else:
            r_ng = mid

    return max(0, r_ok - l_ok - 1)


print(main())


Measured memory_bytes: 41296
#include<stdio.h>
int a[100001],sum;
void abcd(int l,int r)
{int i=l,j=r,t;
int p=a[(l+r)/2];
while(i<=j)
{
    while(a[i]<p)
    {i++;}
    while(a[j]>p)
    {j--;}
    if(i<=j)
    {t=a[i]; 
    a[i]=a[j]; 
    a[j]=t;
    i++; 
    j--;}
    }
    if(l<j)
    abcd(l,j);
    if(i<r)
    abcd(i,r); }
    int main()
    {	
    int i,n,m;	
 	scanf("%d%d",&n,&m);   
  	for(i=1;i<=n;i++)   
    scanf("%d",&a[i]);   
    abcd(1,n);  
    for(i=n;i>n-m;i--)   
    sum+=a[i];
    printf("%d\n",sum);
    return 0;   
    }

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

using namespace std;

int main(void) {
	int k[6], a[5] = { 0 }, i = 0, ans = 0, num = 5;
	for (; i < 5; i++) {
		cin >> k[i];
		if (k[i] % 10 == 0)
			a[i] = 1;
		else {
			if (num == 5)
				num = i;
			else if (k[num] % 10 > k[i] % 10)
				num = i;
		}
	}
	for (i = 0; i < 5; i++) {
		if (a[i] == 1)
			ans += k[i] / 10;
	}
	for (i = 0; i < 5; i++) {
		if (i == num)
			continue;
		if (a[i] == 0) {
			ans++;
			ans += k[i] / 10;
		}
	}
	k[5] = 0;
	ans *= 10;
	ans += k[num];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, T = map(int, input().split())
    AB = sorted([list(map(int, input().split())) for _ in range(N)])
    A = [0] * (N + 1)
    B = [0] * (N + 1)
    for i in range(N):
        A[i + 1], B[i + 1] = AB[i]

    a_max = max(A)
    t_max = T - 1 + a_max
    dp = [[0 for _ in range(t_max + 1)] for _ in range(N + 1)]

    for i in range(N):
        for j in range(t_max + 1):
            if 0 <= (j - A[i + 1]) and (j - A[i + 1]) < T:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j], dp[i][j - A[i + 1]] + B[i + 1])
            else:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

    ans = 0
    for d in dp:
        ans = max(ans, max(d))

    print(ans)

    # for i in range(t_max + 1):
    #     print("{:03},".format(i), end='')
    # print('')
    # for d in dp:
    #     for a in d:
    #         print("{:03},".format(a), end='')
    #     print('')


if __name__ == '__main__':
    solve()


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

int main(){
	long long int n, m, ans = 0;
	cin >> n >> m;
	if (m >= 2*n){
		ans += n;
		m -= 2*n;
	}
	else if(n>0){
		ans += m / 2;
		m = m % 2;
	}
	ans += (long long int)(m / 4);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <cmath>
#define INF 0x3f3f3f
#define MAX 100005
using namespace std;
int ar[55];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        memset(ar,0,sizeof(ar));
        while(m--)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            ar[a]++;
            ar[b]++;
        }
        for(int i=1;i<=n;i++)
            printf("%d\n",ar[i]);
    }
    return 0;
}


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

using namespace std;

using ll = long long;
#define rep(i,n) for(int i = 0; i < n ;++i)
#define all(v) v.begin(),v.end()

int main() {
  int n;
  while(cin >> n) {
    if (n == 0) {
      break;
    }
  vector<string> w(n);
  vector<int> d(n);
  for (int i =0; i < n; i++) {
    cin >> w[i];
    d[i] = w[i].size();
  }
  for (int i = 0; i < n; i++) {
    bool h = true;
    int st[5] = {0};
    int lm[5] = {5, 7, 5, 7, 7};
    int a = 0;
    for (int j = i; j < n; j++) {
      for (int k = a; k < 5; k++) {
        if (st[k] < lm[k]) {
          st[k] += d[j];
          break;
        } else if (st[k] > lm[k]) {
          h = false;
          break;
        }
        a++;
      }
      if (!h) {
        break;
      } else if (a == 5) {
        break;
      }
    }
    if (h) {
      cout << i+1 << endl;
      break;
    }
  }
  }
  return 0;
}

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

int main(){
    int W,H,N;
    cin>>W>>H>>N;
    vector<int> a(N);
    vector<int> x(N);
    vector<int> y(N);

    for(int i=0; i<N; i++) cin>>x[i]>>y[i]>>a[i];

    bool check[110][110] = {false};

    for(int i=0; i<N; i++){
        if(a[i] == 1){
            for(int h=0; h<H; h++){
                for(int w=0; w<x[i]; w++){
                    check[h][w] = true;
                }
            }           
        }

        else if(a[i] == 2){
            for(int h=0; h<H; h++){
                for(int w=x[i]; w<W; w++){
                    check[h][w] = true;
                }
            }
        }

        else if(a[i] == 3){
            for(int w=0; w<W; w++){
                for(int h=0; h<y[i]; h++){
                    check[h][w] = true;
                }
            }
        }

        else if(a[i] == 4){
            for(int w=0; w<W; w++){
                for(int h=y[i]; h<H; h++){
                    check[h][w] = true;
                }
            }
        }
    }

    int ans = H*W;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(check[i][j]) ans--;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

int main(){
    ll D;
    cin >> D;
    vector<ll> c(26), t(D), last(26, -1);
    vector< vector<ll> > s(365, vector<ll> (26));
    rep(i, 0, 26) cin >> c[i];
    rep(i, 0, D){
        rep(j, 0, 26) cin >> s[i][j];
    }
    rep(i, 0, D){
        cin >> t[i];
        t[i]--;
    }
    ll res = 0;
    rep(d, 0, D){
        res += s[d][t[d]];
        last[t[d]] = d;
        rep(j, 0, 26) {
            res -= c[j] * (d - last[j]);
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 100

int main(){
  int i, j, l, k, n, p[N+1];
  double m[N+1][N+1];

  scanf("%d",&n);
  for(i = 1; i <= n; i++) scanf("%d%d",&p[i-1], &p[i]);

  for(i = 1; i <= n; i++) m[i][i] = 0;
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k = i; k <= j - 1; k++) m[i][j] = fmin(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
    }
  }

  printf("%d\n",(int)m[1][n]);

  return 0;
}

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

int pow2(int x, int n) {
  if (n == 0) return 1;
  if (n & 1) return x * pow2(x, n - 1);
  int y = pow2(x, n / 2);
  return y * y;
}

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

  int n, k;
  cin >> n >> k;
  int m = min(n, (int)ceil(log2(k)));
  int res =  pow2(2, m) + k * (n - m);
  cout << res << '\n';
  return 0;
}

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

string s[8];
char c[2]={'o','x'};
int dx[8]={1,1,0,-1,-1,-1,0,1},dy[8]={0,1,1,1,0,-1,-1,-1};
int t;

int dfs(int d,int x,int y){
  if(min(x,y)<0||7<max(x,y)||s[y][x]=='.')return -9;
  if(s[y][x]==c[t])return 0;
  return dfs(d,x+dx[d],y+dy[d])+1;
}

void solve(){
  int ct=0;
  while(ct++<150){  
    int px=-1,py=-1,mx=0;
    for(int y=0;y<8;y++)
      for(int x=0;x<8;x++){
	int xx=x,yy=y,res=0;
	if(t)xx=7-x,yy=7-y;
	if(s[yy][xx]!='.')continue;
	for(int i=0;i<8;i++)res+=max(0,dfs(i,xx+dx[i],yy+dy[i]));
	if(res>mx)px=xx,py=yy,mx=res;
      }
    if(mx)
      for(int i=0;i<8;i++){
	int res=dfs(i,px+dx[i],py+dy[i]);
	for(int j=0;j<=res;j++)
	  s[py+j*dy[i]][px+j*dx[i]]=c[t];
      }
    t=!t;
  }
}

int main(){
  for(int i=0;i<8;i++)cin>>s[i];
  solve();
  for(int i=0;i<8;i++)cout<<s[i]<<endl;
  return 0;
}

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

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

    int res = 0;
    int l = 0, r = S.size() - 1;
    while (l < r)
    {
        if (S.at(l) != S.at(r))
        {
            res++;
        }
        l++;
        r--;
    }
    cout << res << endl;
}

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

using namespace std;
using ll = long long;
#define PI 3.141592653589793238462643383

int main()
{
   double a,b,h,m;
   cin>>a>>b>>h>>m;


double factor = 5/60;
   double new_h = (h*5)+((5*m)/60);


   double angle = 6*abs(new_h-m);
   if(angle>180.0){
    angle = 360.0-angle;

   }



   double answer = cos(angle*PI/180.0);

   answer = 2*a*b*answer;
   answer = a*a+b*b-answer;
   cout<<fixed<<setprecision(15)<<sqrt(answer);




    return 0;
}


Measured memory_bytes: 4216
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m,t,i;
long long ans=0;
int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		ans+=(b-a+1);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 128
n,m = map(int, input().split())
H = list(map(int, input().split()))

l =[]
good_list = set(l)
for i in range(n):
  good_list.add(i+1)

for i in range(m):
  a,b = map(int, input().split())
  high_a = H[a-1]
  high_b = H[b-1]
  if high_a <= high_b:
    good_list.discard(a)
  if high_b <= high_a:
    good_list.discard(b)
    
print(len(good_list))

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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll ans = 0;
    for(i = 1;i <= sqrt(n)+1;++i){
        if(n%i) continue;  
        j = n/i;
        ll m = j-1;
        if(i >= m) continue;
        else ans += m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	fmt.Fprintln(writer, (n-h+1)*(n-w+1))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << ' ';
        }
        s << vec[i];
    }
    return s << endl;
}

int main() {
    string s;
    cin >> s;
    int l = 0;
    int r = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'A') {
            l = i;
            break;
        }
    }
    for (int i = (int)s.size() - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            r = i;
            break;
        }
    }
    cout << r - l + 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <deque>

using namespace std;

int main() {
    string str;
    cin >> str;
    
    deque<char> st;
    for(int n=0; n<str.size(); n++) {
        if(str[n]!='B') {
            st.push_back(str[n]);
        } else {
            if(!st.empty()) {
                st.pop_back();
            }
        }
    }
    
    while(!st.empty()) {
        cout << st.front();
        st.pop_front();
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 256
#入力が横に一行並んでるときはこうする↓
M,D = input().split()
 
count = 0
for i in range(2,int(D)+1):
    if len(str(i)) == 2:
        x = str(i)
        y = x[0:1]
        z = x[1:2]
        for j in range(2,int(M) + 1):
            if int(y) * int(z) == j and int(z) != 1 and int(y) != 1:
                count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

int main(){
   int N;
   std::cin >> N;
   std::string s;
   std::map<std::string, int> mp;
   for(int i=0; i<N; ++i){
      std::cin >> s;
      std::sort(s.begin(), s.end());
      mp[s]++;
   }

   long long ans = 0;
   for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
      long long tmp = itr->second;
      ans += tmp * (tmp-1) / 2;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int n,m,j=1;
   scanf("%d",&n);
   while(n--)
   {
       scanf("%d",&m);
       if(m%2==0&&m>=10)
       {
           if(!(m%6==0||m%10==0))
            j=0;
       }
       else if(m==2||m==4||m==8)
        j=0;
   }
   if(j==1)
    printf("APPROVED\n");
   else
    printf("DENIED\n");
    return 0;
}


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


Measured memory_bytes: 3640
let read_lines n =
  let rec read_lines n acc =
    if n = 0 then List.rev acc
    else read_lines (pred n) ((read_line ()) :: acc) in
  read_lines n []

let score data_set =
  let scores = List.map
                 (fun (a, b) ->
                  let s = a + b in
                  if a > b then (s, 0)
                  else if a < b then (0, s)
                  else (a, b))
                 data_set in
  List.fold_left
    (fun (a_acc, b_acc) (a, b) -> (a_acc + a, b_acc + b))
    (0, 0)
    scores

let rec solve () =
  let n = int_of_string @@ read_line () in
  if n = 0 then ()
  else
    let data_set = List.map
                     (fun line -> Scanf.sscanf line "%d %d" (fun a b -> (a, b)))
                     (read_lines n) in
    let a, b = score data_set in
    Printf.printf "%d %d\n" a b;
    solve ()

let () = solve ()

Measured memory_bytes: 6100
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

fun main() {
    val abcxy = nextIntList()
    val ans = solve(abcxy)
    println(ans)
}

fun solve(abcxy: List<Int>): Int {
    val a = abcxy[0]
    val b = abcxy[1]
    val c = abcxy[2]
    val x = abcxy[3]
    val y = abcxy[4]

    val aaaa = min(x, y) * c * 2
    val bbbbb = a * x + b * y
    val ccccc = max(x, y) * c * 2

    val only = if (x - y > 0) {
        a * (x - y)
    } else {
        b * (y - x)
    }

    return min(min(aaaa + only, bbbbb),ccccc)
}


fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextIntLineList(n: Int): List<List<Int>> {
    return (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
}

fun nextLong(): Long {
    return readLine()!!.toLong()
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 36416