akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;

int main(void)
{
	int i,n,t,x,h;
	double mx,h1;
	scanf("%d %d",&n,&t);
	mx=-1.0;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&x,&h);
		h1=(double)t*h/x;
		mx=max(mx,h1);
	}
	printf("%lf\n",mx);
	return 0;
}


Measured memory_bytes: 2744
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let (n, k) = scan "%d %d" Tuple.Tuple2.make

let () =
  let (_, c) =
    (0 -- 1000) |> Enum.fold (fun (m, c) _ ->
        if n/m  = 0 then (m, c)
        else (m*k, c+1)) (k, 1) in
  printf "%d" c


Measured memory_bytes: 1280
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int a[400][400],n,et;
long long f[400][400],ans;
struct nod{
	int x,y,z;
	bool operator <(const nod&a)const{
		return z<a.z;
	}
};
nod e[100000];
int main(){
	scanf("%d",&n);
	fo(i,1,n) fo(j,1,n) scanf("%d",&a[i][j]);
	fo(i,1,n-1) fo(j,i+1,n){
		e[++et].x=i;
		e[et].y=j;
		e[et].z=a[i][j];
	}
	sort(e+1,e+et+1);
	fo(i,1,n) fo(j,1,n) f[i][j]=0x3fffffff;
	fo(i,1,n) f[i][i]=0;
	fo(ii,1,et){
		int &x=e[ii].x,&y=e[ii].y,&z=e[ii].z;//i ii
		if (a[x][y]>f[x][y]){
			printf("-1\n");
			return 0;
		}
		if (a[x][y]<f[x][y]){
			f[x][y]=f[y][x]=a[x][y];
			ans+=a[x][y];
			fo(i,1,n)
				fo(j,1,n)
					if (f[i][x]+f[x][j]<f[i][j]) f[i][j]=f[i][x]+f[x][j];
			fo(i,1,n)
				fo(j,1,n)
					if (f[i][y]+f[y][j]<f[i][j]) f[i][j]=f[i][y]+f[y][j];
		}
	
	}
	fo(i,1,n)
		fo(j,1,n)
			if (f[i][j]!=a[i][j]){
				printf("-1\n");
				return 0;
			}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
long long knapsack(vector<pair<long,long> > a, long long w){
    long long i,j,n=a.size();
    long long arr[n+1][w+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=w;j++){
            if(i==0 || j==0){
                arr[i][j]=0;
            }
            else{
                if(j-a[i-1].first>=0){
                    arr[i][j]=max(arr[i-1][j],arr[i-1][j-a[i-1].first] + a[i-1].second);
                }
                else{
                    arr[i][j]=arr[i-1][j];
                }
            }
            //cout<<arr[i][j]<<' ';
        
        }
        //cout<<endl;
    }
    return arr[n][w];
}
int main(){
    long long n,i,w;
    cin>>n>>w;
    vector<pair<long,long> > a;
    pair<long,long> p;
    for(i=0;i<n;i++){
        cin>>p.first>>p.second;
        a.push_back(p);
    }
    sort(a.begin(),a.end());
    cout<<knapsack(a,w)<<endl;
}

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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "

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

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

    vector<int> dp(n);
    
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for(int i = 2; i < n; ++i) {
        dp[i] = min(dp[i-2] + abs(v[i] - v[i-2]), dp[i-1] + abs(v[i] - v[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll power(ll a,ll n,ll mod){
	if(n == 0) return 1 % mod;
	ll p = power(a,n/2,mod);
	p = (p * p) % mod;
	if(n % 2) p = (p * a) % mod;
	return p;
}
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll bits = 0;

	REPI(i,0,n){
		if(s[i] == '1'){
			bits++;	
		}
	}

	ll p1 = 1;
	ll ans1 = 0;

	REPI(i,0,n){
		if(s[i] == '1'){
			ans1 = (ans1 + p1) % (bits+1);
		}
		p1 = (p1 * 2) % (bits+1);
	}

	ll ans2 = 0;
	p1 = 1;
	
	if(bits-1 > 0)
	{
		REPI(i,0,n){
			if(s[i] == '1'){
				ans2 = (ans2 + p1) % (bits-1);
			}
			p1 = (p1 * 2) % (bits-1);
		}
	}
	
	ll ans[n] = {0};

	REP(i,0,n)
	{
		if(s[i] == '1')
		{
			if(bits-1 == 0){
				ans[i] = 0;
				continue;
			}
			
			ll p = (ans2 - power(2,n-i-1,bits-1) + bits-1) % (bits-1);
			// cout<<p<<endl;

			ans[i]++;

			while(p > 0){
				ll x = 0;
				REP(j,0,32){
					if((p >> j) & 1){
						x++;
					}
				}
				p = p % x;
				ans[i]++;
			}
		}
		else 
		{
			ll p = (ans1 + power(2,n-i-1,bits+1)) % (bits+1);
			// cout<<p<<endl;

			ans[i]++;
			while(p > 0){
				ll x = 0;
				REP(j,0,32){
					if((p >> j) & 1){
						x++;
					}
				}
				p = p % x;
				ans[i]++;
			}
		}
	}
	REP(i,0,n) cout<<ans[i]<<endl;
	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;

cout<<min(a,b)+min(c,d)<<endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

const int MAX_N = 1e3 + 1;

ll X[MAX_N], Y[MAX_N];

int main() {
    int N;
    cin >> N;
    bool is_odd = false;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        if ((X[i] + Y[i]) % 2) is_odd = true;
    }
    for (int i = 0; i < N; i++) {
        if (is_odd && !((X[i] + Y[i]) % 2)) {
            cout << -1 << endl;
            return 0;
        }
    }
    int M = 31 + (is_odd ? 0 : 1);
    cout << M << endl;
    for (int i = 0; i < M; i++) {
        if (i == 31) cout << 1;
        else cout << (1 << i) << ' ';
    }
    cout << endl;
    for (int i = 0; i < N; i++) {
        ll U = X[i] + Y[i], V = X[i] - Y[i];
        ll u_mask = (U + ((1LL << 31) - 1)) / 2, v_mask = (V + ((1LL << 31) - 1)) / 2;
        string ans = "";
        for (int j = 0; j < 31; j++) {
            if (((u_mask >> j) & 1) && ((v_mask >> j) & 1)) {
                ans.push_back('R');
            }
            else if (((u_mask >> j) & 1) && !((v_mask >> j) & 1)) {
                ans.push_back('U');
            }
            else if (!((u_mask >> j) & 1) && ((v_mask >> j) & 1)) {
                ans.push_back('D');
            }
            else ans.push_back('L');
        }
        ll x = 0, y = 0;
        for (int i = 0; i < 31; i++) {
            if (ans[i] == 'R') x += (1LL << i);
            else if (ans[i] == 'L') x -= (1LL << i);
            else if (ans[i] == 'U') y += (1LL << i);
            else y -= (1LL << i);
        }
        if (x < X[i]) ans.push_back('R');
        else if (y < Y[i]) ans.push_back('U');
        else if (x > X[i]) ans.push_back('L');
        else if (y > Y[i]) ans.push_back('D');
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n,w;
	while(scanf("%d %d",&n,&w),n) {
		int cnt[11]={0};
		int m=0,h=0;
		for(int i=0;i<n;i++) {
			int v;
			scanf("%d",&v);
			cnt[v/w]++;
			m=max(m,v/w);
		}
		for(int i=0;i<=m;i++) {
			h=max(h,cnt[i]);
		}
		double sum=0.01;
		double color=1;
		for(int i=0;i<=m;i++) {
			sum+=color*((double)cnt[i]/h);
			color-=1.0/m;
		}
		printf("%.15lf\n",sum);
	}
}

Measured memory_bytes: 3088
#![allow(unused_imports)]
use proconio::*;
use num::Integer;

#[fastout]
fn main() {
   input! {
       n: usize,
       s: String
   }
   let r = s.match_indices("R").count();
   let g = s.match_indices("G").count();
   let b = s.match_indices("B").count();
   let mut ans = r*g*b;
   let v = s.as_bytes();
   for i in 0..n {
       let mut j = 1;
       while i+2*j < n {
           if v[i]!=v[i+j]&&v[i+j]!=v[i+2*j]&&v[i]!=v[i+2*j] {
               ans-=1;
           }
           j += 1
       }
   }
   println!("{}", ans);
}


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

#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
double pi= 3.14159265358979;
const int N=2e5+5;

void solve()
{   
	int a,b,c,d, k; cin>>a>>b>>c>>d>>k;
	int ans = (c-a)*60+d-b;
	cout<<max(ans-k, 0ll);
}

signed main() 
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // cout<<setprecision(6);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3652
/************************************
 TEMPLATE FOR PROGRAM COMPETITION
 ***********************************/
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

// s, t < 3000

int main(){

  // read s, t
  char s[3001], t[3001];
  long long int s_len, t_len;
  scanf("%s", s);
  scanf("%s", t);
  
  s_len = strlen(s);
  t_len = strlen(t);
  
  // check problem
  /*std::cerr << "s: " << s << " (length: " << s_len << ")" << std::endl;
  std::cerr << "t: " << t << " (length: " << t_len << ")" << std::endl;*/
  
  // solve problem
  // dp_table[i][j] : the max length of subsequence of both of the first i-letters of s and the first j-letters of t
  std::vector< std::vector<long long int> > dp_table(3001);
  for(int i = 0; i < 3001; i++){
    for(int j = 0; j < 3001; j++){
      dp_table[i].push_back(0);
    }
  }
  /*int dp_table[3001][3001];
  
  for(int i = 0; i < 3001; i++){
    dp_table[0][i] = 0;
    dp_table[i][0] = 0;
  }*/
  
  
  for(int i = 1; i <= s_len; i++){
    for(int j = 1; j <= t_len; j++){
      // if s[i-1] and t[i-1] can be used in the subsequence of s and t
      if(s[i-1] == t[j-1]){
        dp_table[i][j] = std::max(std::max(dp_table[i-1][j-1]+1, dp_table[i-1][j]), dp_table[i][j-1]);
      }
      // if s[i-1] and t[i-1] cannot be used in the subsequence of s and t
      else{ // if (s[i-1] != t[i-1])
        dp_table[i][j] = std::max(dp_table[i][j-1], dp_table[i-1][j]);
      }
    }
  }
  
  // check table
  /*for(int i = 0; i <= s_len; i++){
    for(int j = 0; j <= t_len; j++){
      std::cerr << dp_table[i][j] << " ";
    }std::cerr << std::endl;
  }*/

  // backtracking
  char sub[3001];
  int sub_len = 0;
  
  int i_tmp = s_len, j_tmp = t_len;
  
  while(dp_table[i_tmp][j_tmp] != 0){
    if(s[i_tmp-1] == t[j_tmp-1] && dp_table[i_tmp][j_tmp] == dp_table[i_tmp-1][j_tmp-1]+1){
      sub[sub_len] = s[i_tmp-1];
      sub_len++;
      i_tmp--;
      j_tmp--;
    }
    else if(dp_table[i_tmp][j_tmp] == dp_table[i_tmp][j_tmp-1]){
      j_tmp--;
    }
    else if(dp_table[i_tmp][j_tmp] == dp_table[i_tmp-1][j_tmp]){
      i_tmp--;
    }
  }
  
  for(int i = sub_len-1; i >= 0; i--){
    std::cout << sub[i];
  }
  
  return 0;
}



Measured memory_bytes: 82688
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 1000001;
const int mod = 1000000007;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
vector<int> isPrime(MAX, 1);
vector<int> prime, a;
vector<map<int, int> > factor;
int N;
/* function */
void eratos() {
    isPrime[0] = isPrime[1] = 0;
    for (int i = 2; i*i < MAX; i++) {
        if (isPrime[i]) {
            for (int j = i * 2; j < MAX; j += i) isPrime[j] = 0;
        }
    }
    for (int i = 0; i < MAX; i++) if (isPrime[i]) prime.push_back(i);
}

void primeFactorization() {
    for (int i = 0; i < N; i++) {
        int x = a[i];
        if (x < 2) {
            factor[i][x]++;
            return ;
        }
        for (int j = 0; prime[j] * prime[j] <= a[i]; j++) {
            while (x%prime[j] == 0) {
                factor[i][prime[j]]++;
                x /= prime[j];
            }
        }
        if (x != 1) factor[i][x]++;
    }
    return;
}
/* main */
int main(){
    cin >> N;
    factor.assign(N, map<int, int>());
    a.resize(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    eratos();
    primeFactorization();

    /*
    for (int i = 0; i < N; i++) {
        cout << a[i] << " : ";
        for (auto f : factor[i]) {
            cout << f.first << "^" << f.second << "*";
        } cout << '\n';
    }
    */
    map<int, int> gcd;
    for (int i = 0; i < N; i++) {
        for (auto f : factor[i]) {
            gcd[f.first] = max(gcd[f.first], f.second);
        }
    }
    mint L = 1;
    for (auto g : gcd) {
        mint b = g.first;
        L *= b.pow(g.second);
    }
    mint ans = 0;
    for (int i = 0; i < N; i++) {
        mint x = a[i];
        ans += L / x;
    }

    cout << ans << '\n';
}


Measured memory_bytes: 7292
def ceil(a0,b0):
  if a0%b0 == 0:
    return a0//b0
  else:
    return a0//b0 +1

t_num,a_num = 1,1

n = int(input())

for i in range(n):
    t,a = map(int,input().split())
    k = max(ceil(t_num,t),ceil(a_num,a))
    #その比に票を合わせる
    t_num = k*t
    a_num = k*a
    #print([t_num,a_num])    

print(t_num + a_num)


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

int main(){
  long long N;
  cin>>N;
  vector<long long> A(N+1),B(N);
  for(long long &i:A)
    cin>>i;
  for(long long &i:B)
    cin>>i;
  long long j=0,k=A[0];
  for(long long i=0;i<N;i++){
    if(k+A[i+1]-B[i]>0){
      j+=B[i];
      k=A[i+1]-max(B[i]-k,0LL);
    }else{
      j+=k+A[i+1];
      k=0;
    }
  }
  cout<<j<<endl;
}

Measured memory_bytes: 1792
from collections import Counter

n, m = map(int, input().split())
l = [list(map(int, input().split()))[1:] for _ in range(n)]
#1次元に変換
r = []
for row in l:
  for i in row:
    r.append(i)
c = dict(Counter(r))
ans = 0
for value in c.values():
  if value == n:
    ans += 1
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    while(true) {
        if(a * cnt - (cnt - 1) < b) cnt++;
        else break;
    }
    cout << cnt << endl;
    
    return 0;
}

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

main(int argc, char const *argv[])
{
	int n,l,r;
	while(cin>>n>>l>>r,n)
	{
		int a[n],ans=0;
		for (int i = 0; i < n; ++i)
		{
			cin>>a[i];
		}

		for (int i = l; i <= r; ++i)
		{
			int f=1;
			for (int j = 0; j < n; ++j)
			{
				if(i%a[j]==0)
				{
					if(f%2) ++ans;
					f=0;
					break;
				}
				++f;
			}
			if(f%2) ++ans;
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

int main(){
	int h,w; cin>>h>>w;
	vector<vector<string>> a(h+1,vector<string>(w+1,"."));
	rep(i,h){
		string s; cin>>s;
		rep(j,w){
			a[i][j]=s[j];
		}
	}
	int cnt=0;
	rep(i,h){
		rep(j,w){
			if(a[i][j]=="#") cnt++;
		}
	}
	int ans=1;
	int j=0;
	rep(i,h){
		if(a[i+1][j]=="#") {ans++;}
		else if(a[i][j+1]=="#") {ans++; i--; j++;}
	}
	cout<<(cnt==ans?"Possible":"Impossible")<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		DiceOri dice=new DiceOri(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		int q=sc.nextInt();
		for(int i=0;i<q;i++) {
			System.out.println(dice.Right(sc.nextInt(),sc.nextInt()));
		}
	}
}
class DiceOri{
	int Top;
    int Bottom;
    int Nth;
    int Sth;
    int Wst;
    int Est;
    DiceOri(int a, int b, int c, int d, int e, int f) {
        Top = a;
        Sth = b;
        Est = c;
        Wst = d;
        Nth = e;
        Bottom = f;
    }
	public void TurnN() {
		int empty=Top;
		Top=Sth;
		Sth=Bottom;
		Bottom=Nth;
		Nth=empty;
	}
	public void TurnW() {
		int empty=Top;
		Top=Est;
		Est=Bottom;
		Bottom=Wst;
		Wst=empty;
	}
	public void TurnS() {
		int empty=Top;
		Top=Nth;
		Nth=Bottom;
		Bottom=Sth;
		Sth=empty;
	}
	public void TurnE() {
		int empty=Top;
		Top=Wst;
		Wst=Bottom;
		Bottom=Est;
		Est=empty;
	}
	public int Right(int x,int y) {
		if((x==Top && y==Sth) || (x==Sth && y==Bottom) || (x==Bottom && y==Nth) || (x==Nth && y==Top)) {
			return Est;
		}else if((x==Wst && y==Sth) || (x==Sth && y==Est) || (x==Est && y==Nth) || (x==Nth && y==Wst)) {
			return Top;
		}else if((x==Est && y==Bottom) || (x==Bottom && y==Wst) || (x==Wst && y==Top) || (x==Top && y==Est)) {
			return Nth;
		}else if((x==Sth && y==Top) || (x==Top && y==Nth) || (x==Nth && y==Bottom) || (x==Bottom && y==Sth)) {
			return Wst;
		}else if((x==Est && y==Top) || (x==Top && y==Wst) || (x==Wst && y==Bottom) || (x==Bottom && y==Est)) {
			return Sth;
		}else {
			return Bottom;
		}
	}
}


Measured memory_bytes: 26112
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) {
        try {
			final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			final String key = input.readLine();
			int count = 0;
			String[] strs;
			while(true){
			    strs = input.readLine().split(" ");
			    if (strs[0].equals("END_OF_TEXT")) {
			    	break;
			    }
			    for(int i = 0; i < strs.length; i++){
			        final String str = strs[i];
			        if(str.equalsIgnoreCase(key)){
			            count++;
			        }
			    }
			}
			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}

Measured memory_bytes: 16916
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;
using ll=int64_t;
int main()
{
  int n;
  cin>>n;
  vector<pair<ll,ll>> xl(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>xl[i].first>>xl[i].second;
  }
  sort(xl.begin(), xl.end(),[](auto lhs,auto rhs){
    return lhs.first+lhs.second<rhs.first+rhs.second;
  });
  ll ans=1;
  ll lim=xl[0].first+xl[0].second;
  for (int i = 1; i < n; ++i)
  {
    if(xl[i].first-xl[i].second>=lim)
    {
      ans++;
      lim=xl[i].first+xl[i].second;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 1792
H, W = map(int, input().split())
lst = [list(input()) for _ in range(H)]

ans = 0
for ia in range(H):
    for ja in range(W):
        for ib in range(H):
            for jb in range(W):
                if lst[ia][ja] == 'B' and lst[ib][jb] == 'B':
                    tmp = abs(ia-ib) + abs(ja-jb)
                    ans = max(ans, tmp)

print (ans)



Measured memory_bytes: 5604
#include<cstdio>
int main(void){

    int count=0;
    while(true){
        int a=0;
        scanf("%d",&a);
        if(a==0){
            break;
        }
        count++;
        printf("Case %d: %d\n",count,a);
        
    }
    return 0;
}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back        
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 2e5 + 123;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const ll infl = 3e18 + 1;
const double pi = acos(-1.0);

inline void boost () {
    ios_base::sync_with_stdio (0);
    cin.tie (0); cout.tie (0);
}
inline void SmartRandom228 () {
	unsigned int key;
	asm ("rdtsc" : "=A"(key));
	srand (key);
}


int main () {
	boost ();
	string s;
	cin >> s;
	int S = 0;
	s += "#";
	int ans = sz (s) - 1;
	for (int i = 0;i < sz (s) - 1;i ++) {
		if (s[i] == 'S' && s[i + 1] == 'T') {
		    ans -= 2;
		    i ++;
		    continue; 
		}
		if (s[i] == 'S') S ++;
		else {
			if (S > 0) S --, ans -= 2;
		} 
	}
	cout << ans;
return 0;       
}
                                                          

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=5005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int ans=1e9,n,a[MAXN],b[MAXN],cnt1,cnt2;char s1[MAXN],s2[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),scanf("%s%s",s1+1,s2+1);
	Rep(i,1,n-1)if(s1[i]!=s1[i+1])a[++cnt1]=i;
	Rep(i,1,n-1)if(s2[i]!=s2[i+1])b[++cnt2]=i;
	Rep(i,-cnt1-1,cnt2+1)if((i&1)^(s1[1]==s2[1])){
		int tmp=0;
		Rep(j,min(1,1-i),max(cnt1,cnt2-i))
			tmp+=abs((j<0?0:j>cnt1?n:a[j])-(i+j<0?0:i+j>cnt2?n:b[i+j]));
		ans=min(ans,tmp);
	}cout<<ans<<'\n';
	return 0;
}




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

int main() {
	vector<int> p(3);
	int r = 1;
	for (int i = 0; i < 3; i++) {
		cin >> p[i];
		for (int j = 0; j < i; j++) {
			if (p[i] == p[j]) {
				break;
			}
			if (j == i - 1) {
				r++;
			}
		}
	}

	cout << r << endl;
}

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

using namespace std;

//#define FILE_IO

int N, ans;
int startB, endA, both;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    cin >> N;
    ans = 0;
    for(int i = 1; i <= N; i++)
    {
        string s;
        cin >> s;
        for(int i = 1; i < s.size(); i++)
            if(s[i - 1] == 'A' && s[i] == 'B')  ans++;

        if(s[0] == 'B' && s.back() == 'A')  both++;
        else if(s[0] == 'B') startB++;
        else if(s.back() == 'A') endA++;
    }

    int add = max(0, both - 1);
    if(both && endA)
    {
        endA--;
        add++;
    }
    if(both && startB)
    {
        startB--;
        add++;
    }

    add += min(startB, endA);
    ans += add;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    long N;
    cin >> N;
    long tmp;
    vector<long> trans;
    
    for(int i = 0; i < 5; i++){
        cin >> tmp;
        trans.push_back(tmp);        
    }

    long mini = *min_element(trans.begin(), trans.end());
    
    long add;
    
    if(N%mini==0) add = N/mini;
    else add = N/mini+1;

    cout << 4 + add << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong(), s = scanner.nextLong();
			if (n < s) {
				// https://atcoder.jp/contests/abc044/submissions/4095161 参考に追加
				System.out.println(-1);
			} else if (n == s) {
				System.out.println(n + 1);
			} else {
				int sqrtN = (int) Math.sqrt(n);
				for (int b = 2; b <= sqrtN; b++) {
					if (s == f(b, n)) {
						System.out.println(b);
						return;
					}
				}
				for (int p = sqrtN; p >= 1; p--) {
					long b = (n - s) / p + 1;
					if ((b > sqrtN) && (b > p) && (s == f(b, n))) {
						System.out.println(b);
						return;
					}
				}
				System.out.println(-1);
			}
		}
	}

	/**
	 * @param b
	 * @param n
	 * @return f(b,n)
	 */
	private static long f(long b, long n) {
		if (n < b) {
			return n;
		} else {
			return f(b, n / b) + n % b;
		}
	}
}


Measured memory_bytes: 35776
from collections import Counter

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


N = n_in()
S = []
counter = Counter()

for i in range(N):
    counter[s_in()] += 1


t = counter.most_common()[0][1]
for s in sorted((map(lambda a: a[0], filter(lambda a: a[1] == t,  counter.most_common())))):
    print(s)



Measured memory_bytes: 43564
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123;
char s[3][MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < 3; i++) scanf("%s", s[i]);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int mv = 3;
        for (int j = 0; j < 3; j++) {
            int cnt = 0;
            for (int k = 0; k < 3; k++) {
                if (s[j][i] != s[k][i]) cnt++;
            }
            mv = min(mv, cnt);
        }
        ans += mv;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main()
{	int a,b;
	char op;
	while(1){
	scanf("%d %c %d",&a,&op,&b);
	if(op == '?')break;
	switch(op){
		case '+':printf("%d\n",a+b); break;
		case '-':printf("%d\n",a-b); break;
		case '*':printf("%d\n",a*b); break;
		case '/':printf("%d\n",a/b); break;}
	}
	
	return 0;
}

Measured memory_bytes: 600
N, M, K = map(int, input().split())
answer = set()
for i in range(M+1):
    # iは列で見たときの裏の数
    flipped = N*i
    for j in range(N+1):
        answer.add(flipped + ((M-i)-i)*j)

if K in answer:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20884
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int a[] = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }

        double deno = 0;

        for(int i = 0; i < N; i++) {
            deno += 1.0/a[i];
        }

        double answer = 1.0/deno;

        os.println(answer);
    }
}

Measured memory_bytes: 23892
S = input()

for i in range(2**3):
    exp = []
    for j in range(4):
        exp.append(S[j])
        if j == 3:
            None
        elif ((i >> j) & 1):
            exp.append('+')
        else:
            exp.append('-')
    
    a = 0
    neg = False
    for j in range(len(exp)):
        if exp[j] == '-':
            neg = True
        elif exp[j] == '+':
            neg = False
        else:
            if neg:
                a -= int(exp[j])
            else:
                a += int(exp[j])
    
    if a == 7:
        print(''.join(exp)+'=7')
        break

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

int main(){
    int x;
    cin >> x;
    
    switch (x){
        case 7:
        case 5:
        case 3:
            cout << "YES" << endl;
            break;
        default:
            cout << "NO" << endl;
            break;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;
  int a[N];
  rep(i, 0, N) cin >> a[i];

  double ave = accumulate(a, a+N, 0.0) / N;
  double ans = 0;
  double min = fabs(ave-a[0]);
  rep(i, 1, N) {
    if (min > fabs(ave-a[i])) ans=i, min=fabs(ave-a[i]);
  }

  cout << ans << "\n";
}

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

int display_lack(int arr[13], char ch) {
    for (int i = 1; i <= 13; i++) {
        if (arr[i] == 0) {
            cout << ch << ' ' << i << endl;
        }
    }

    return 0;
}

int main(){
    int S[13], H[13], C[13], D[13];
    char ch;
    int x, n;

    for (int i = 1; i <= 13; i++) {
        S[i] = H[i] = C[i] = D[i] = 0;
    }

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> ch >> x;

        switch(ch) {
            case 'S': S[x] = 1; break;
            case 'H': H[x] = 1; break;
            case 'C': C[x] = 1; break;
            case 'D': D[x] = 1; break;
        }
    }

    display_lack(S, 'S');
    display_lack(H, 'H');
    display_lack(C, 'C');
    display_lack(D, 'D');

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> c(n);
    vector<pair<int,int>> A;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        A.emplace_back(a,b);
    }
    sort(A.begin(),A.end());
    // rep(i,n){
    //     cout<<A[i].first<<endl;
    // }
    c[0] = A[0].second;
    rrep(i,n-1){
        c[i] = (ll)c[i-1]+A[i].second;
    }
    auto t = distance(c.begin(),lower_bound(c.begin(),c.end(),k));
    cout << A[t].first << endl;
    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
using namespace std;
typedef long long LL;

int main() {
	LL x;
	cin >> x;

	LL ans = 0;

	LL a = x % 11;
	if (a <= 6&&(a!=0))ans++;
	else if (a == 0)ans += 0;
	else ans += 2;

	x -= a;
	LL b = x / 11;
	b *= 2;
	ans += b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string n;
    cin >> n;
    int ans=0;
    int l = n.size();
    for(int i=1;i<l+1;++++i){
        double r = pow(10,i-1);
        // cout << r << endl;
        if(i==l){
            int h = stoi(n);
            ans+=(h-r+1);
        }
        else{
            ans+=(9*r);
            // cout << ans << endl;
        }
    }
    cout << ans;
    



    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n; cin >> n;
    string ans = "";
    while (n > 0) {
        n--;
        ans += ('a' + (n % 26));
        n /= 26;
    }

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3 = y2 - y1;
    x3 = x2 - x3;
    int y3 = x2 - x1;
    y3 = y2 + y3;
    int x4 = x3 - (x2 - x1);
    int y4 = y3 - (y2 - y1);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e5 + 9;
vector<int> T[N];

bool is[N];

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  int a, b;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> a >> b;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  int node = 1;
  is[node] = true;
  deque<int> ff;
  ff.push_back(node);
  bool ok = true;
  while(ok){
    ok = false;
    node = ff.front();
    for(auto x : T[node]){
      if(!is[x]){
        ff.push_front(x);
        is[x] = true;
        ok = true;
        break;
      }
    }
    node = ff.back();
    for(auto x : T[node]){
      if(!is[x]){
        ff.push_back(x);
        is[x] = true;
        ok = true;
        break;
      }
    }
  }
  cout << ff.size() << "\n";
  while(!ff.empty()){
    cout << ff.front() << " ";
    ff.pop_front();
  }
  return 0;
}

Measured memory_bytes: 6740
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
map<int,LL> now,nex;
mp a[200000+20];
bool cmp(mp A,mp B){
	return (LL)(A.FIR)*(B.SEC+1)>(LL)(B.FIR)*(A.SEC+1); 
}
bool cmp2(mp A,mp B){
	return A>B;
}
int main(){
	fastio;
	int n;LL t;
	cin>>n>>t;
	rb(i,1,n)
		cin>>a[i].FIR>>a[i].SEC;
	sort(a+1,a+1+n,cmp);
	now[0]=0;
	vector<LL> v;
	rb(i,1,n){
		if(a[i].FIR==0){
			v.PB(a[i].SEC);
			continue;
		}
		nex.clear(); 
		for(map<int,LL> :: IT ite=now.begin();ite!=now.end();ite++){
			LL new_time=ite->SEC;
			if(new_time>t) continue;
			if(nex.find(ite->FIR)==nex.end()) nex[ite->FIR]=INF;
			if(nex.find(ite->FIR+1)==nex.end()) nex[ite->FIR+1]=INF;
			new_time++;
			new_time+=new_time*a[i].FIR+a[i].SEC;
			nex[ite->FIR]=min(nex[ite->FIR],ite->SEC);
			nex[ite->FIR+1]=min(nex[ite->FIR+1],new_time);
		} 
		now=nex; 
	}
	sort(ALL(v));
	rep(i,v.size()){
		if(i){
			v[i]+=v[i-1]+1;
		}
	}
	vector<mp> res;
	for(map<int,LL> :: IT ite=now.begin();ite!=now.end();ite++){
		if(ite->SEC<=t) res.PB(II(ite->FIR,t-ite->SEC-1));
	}
	rep(i,res.size()){
		res[i].FIR+=upper_bound(ALL(v),res[i].SEC)-v.begin();
	}
	sort(ALL(res),cmp2);
	cout<<res[0].FIR<<endl;
	return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        double target = scanner.nextDouble();
    //    long start = System.currentTimeMillis(); 
        long ans = calc(target);
    //    long end = System.currentTimeMillis(); 
    //    long time = end - start;
        System.out.println(ans );
    //    System.out.println(time +"ms");
    }
    
    /**
     * @param target
     * @return
     */
    public static  long calc(double target){
        long targetNum = (long)target;
        long divNum = 0;
        divNum = (long) Math.sqrt(target);
        for (long i = divNum; i > 0; i--) 
        {
            if (targetNum % i == 0 ) 
            {
                divNum = i;
                break;
            }
        }
        return (targetNum / divNum) + divNum -2;
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
typedef long double lb;
using namespace std;
int main(){
  int N;
  cin >> N;
  for(int i = 1; i <= N; i++){
    ll P,Q,R;
    cin >> P >> Q >> R;
    int O = max(P,max(Q,R));
    if(O * O == P * P + Q * Q + R * R - O * O){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}


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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	unordered_set<string> S;
	string s;
	for(int i=0; i<n; i++) {
		cin>>s;
		S.insert(s);
	}
	cout<<S.size();
}


Measured memory_bytes: 17760
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#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 pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll calc(ll b,ll n) {
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {

	int n;

	ll a, b;
	cin >> n >> a >> b;
	ll bef = 0;
	ll res = 0;
	for (size_t i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		if (i > 0) {
			res += min(a * (x - bef),b);
		}
		bef = x;
	}

	
	cout << res << endl;
}


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



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

int main(){
	string s;
	cin >> s;
	int n=s.size();
	vector<int> ans(n);
	int r=0,l;
	rep(i,n){
		if(i==n-1){
			r = n;
			ans[l-1] += (r-l)/2;
			ans[l] += (r-l)/2 + (r-l)%2;
			break;
		}
		if(s[i]=='R' && s[i+1]=='L'){
			l=i+1;
			ans[i] += (l-r)/2 + (l-r)%2;
			ans[i+1] += (l-r)/2;
		}
		if(s[i]=='L' && s[i+1]=='R'){
			r=i+1;
			ans[l-1] += (r-l)/2;
			ans[l] += (r-l)/2 + (r-l)%2;
		}
	}
	rep(i,n) cout << ans[i] << endl;
	return 0;
}

			





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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<ll> a(n), prf(n + 1, 0), suf(n + 1, 0), dp(n + 1, 0);
	REPU(i, 0, n) cin >> a[i];
	REPU(i, 0, n) {
		prf[i + 1] = prf[i] + max(0LL, a[i]);
		dp[i + 1] = dp[i] + a[i];
	}
	suf[n] = max(0LL, a[n - 1]);
	REPD(i, n - 2, -1) {
		suf[i + 1] = suf[i + 2] + max(0LL, a[i]);
	}
	ll ans = 0;
	amax(ans, max(0LL, dp[k]) + suf[k + 1]);
	amax(ans, max(0LL, dp[n] - dp[n - k]) + prf[n - k]);
	REPU(i, 0, n - k) {
		ll tmp = prf[i] + max(0LL, dp[i + k] - dp[i]) + suf[i + k + 1];
		amax(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    int ans = max(a+b,max(a-b,a*b));
    ANS;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace Volume6_0654
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string text = Console.ReadLine();
			int ox_cnt = 0;

			// n <= 1の場合は0確定
			if(n <= 1) {
				Console.WriteLine(0);
				return;
			}

			char[] s = text.ToCharArray();
			for(int i = 0; i < n - 1; i++) {
				if(s[i] != s[i + 1]) {
					ox_cnt++;
					s[i] = '-';
					s[i + 1] = '-';
					i++;
				}
			}

			Console.WriteLine(ox_cnt);
		}
	}
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] h = new long[n];
		Arrays.setAll(h, i -> sc.nextInt());
		Arrays.sort(h);
		
		long cnt = 0;
		for (int i = 0; i < n - k; i++) {
			cnt += h[i];
		}
		
		System.out.println(cnt);
	}
}


Measured memory_bytes: 66240