akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
using namespace std;
struct state {
	vector<int> v;
	long long cost;
};
int n, id[19], p[19], w[19], sum[32777], popcount[32777]; state dp[19][32777];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> id[i] >> p[i] >> w[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			sum[j] = sum[j - (1 << i)] + w[i] * 20;
			popcount[j] = popcount[j - (1 << i)] + 1;
		}
	}
	for (int i = 0; i < n; i++) dp[i][1 << i] = state({ vector<int>({i}), 0 });
	for (int i = 1; i < 1 << n; i++) {
		if (popcount[i] == 1) continue;
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) continue;
			dp[j][i].cost = 1LL << 60;
			int sub = i - (1 << j);
			for (int k = 0; k < n; k++) {
				if (!(sub & (1 << k))) continue;
				long long cost = dp[k][sub].cost + 1LL * (70 + sum[sub]) * abs(p[j] - p[k]);
				if (dp[j][i].cost > cost) {
					dp[j][i].cost = cost;
					dp[j][i].v = dp[k][sub].v;
					dp[j][i].v.push_back(j);
				}
			}
		}
	}
	int pos = 0;
	for (int i = 1; i < n; i++) {
		if (dp[i][(1 << n) - 1].cost < dp[pos][(1 << n) - 1].cost) {
			pos = i;
		}
	}
	vector<int> ret = dp[pos][(1 << n) - 1].v;
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		cout << id[ret[i]];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 39084
#include <iostream>

int main()
{
    int a,b;
    char op;

    while(1)
    {
        std::cin >> a >> op >> b;

        switch (op)
        {
            case '+':
            std::cout << a + b << std::endl;
            break;

            case '-':
            std::cout << a - b << std::endl;
            break;

            case '*':
            std::cout << a * b << std::endl;
            break;

            case '/':
            std::cout << a / b << std::endl;
            break;

            case '?':
            return 0;
        }
    }
}


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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    int mx = a[0];
    int imx = 0;
    int mn = a[0];
    int imn = 0;
    rep(i, n) {
        if (a[i] > mx) {
            mx = a[i];
            imx = i;
        }
        if (a[i] < mn) {
            mn = a[i];
            imn = i;
        }
    }

    cout << 2*n - 1 << endl;
    if (abs(mx) >= abs(mn) || mn >= 0) {
        rep(i, n) {
            if (i != imx) {
                a[i] += a[imx];
                cout << imx + 1 << " " << i + 1 << endl;
            }
        }
        a[imx] += a[imx];
        cout << imx+1 << " " << imx + 1 << endl;
        rep(i, n-1) {
            a[i+1] += a[i];
            cout << i+1 << " " << i+2 << endl;
        }
    } else {
        rep(i, n) {
            if (i != imn) {
                a[i] += a[imn];
                cout << imn+1 << " " << i + 1 << endl;
            }
        }
        a[imn] += a[imn];
        cout << imn+1 << " " << imn + 1 << endl;
        for (int i = n-1; i > 0; i--) {
            a[i-1] += a[i];
            cout << i+1 << " " << i << endl;
        }

    }


    return 0;
}


    


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val X = math.abs(sc.nextLong)
  val K, D = sc.nextLong

  val a = X / D
  val b = X % D
  val c = if (math.abs(b - D) == b) b else Long.MaxValue
  val d =
    if (K - a < 0) X - D * K
    else if ((K - a) % 2 == 0) b
    else math.min(math.abs(b - D), c)

  println(d)
}


Measured memory_bytes: 55264
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int [] R = new int[n]; 
		for(int k=0; k<n; k++) {
			R[k] = scan.nextInt();
		}
		System.out.println(compute_maxprofit(n, R));
	}
	    public static int compute_maxprofit(int n, int[] R) {
	    	int max_profit = Integer.MIN_VALUE;
	    	int j = R[0];
	    	for(int i = 1; i<n; i++) {
	    		int current_profit = R[i] - j;
	    		if (max_profit < current_profit) {
	    			max_profit = current_profit;
	    		}
	    		if (R[i] < j) {
	    			j = R[i];
	    		}
	    	}
	    	return max_profit;
	    	
	    	
	    }    
}



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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, d;
int a[50][50];

int main()
{
	IOS;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int s = 0;
			for (int k = 0; k < d; k++) {
				s += ((a[i][k] - a[j][k]) * (a[i][k] - a[j][k]));
			}
			int ss = (int)sqrt(s);
			if (ss * ss == s) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}



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

const int MAXN = 2e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

int a[MAXN],b[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    ll a,b;cin >> a >> b;
    cout << (a*b) / __gcd(a,b);
}


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

using namespace std;

int main() {
	int N; cin >> N;
	
	auto maxOps = 0xFFFFFFFFu;
	while (N--) {
		int A; cin >> A;
		
		auto ops = 0u;
		while (A % 2 == 0) {
			ops++;
			A /= 2;
		}
		maxOps = min(ops, maxOps);
	}
	
	cout << maxOps << endl;
}

Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))+[0]
S=sum(abs(x-y)for x,y in zip(A,A[1:]))
for i in range(1,N+1):
    print(S-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))

Measured memory_bytes: 14048
// ABC 119 B

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  const float RATE = 380000.0;
  int n;
  cin >> n;
  float ans = 0;
  rep (i, n) {
    float x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += (x * RATE);
    }
  }

  printf("%f\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdint>

int const MAXN = 100000;
int const MOD = 1000000007;

int N;
std::vector<int> G[MAXN];
int64_t dp[2][MAXN];

int64_t calc(int bw, int v, int p) {
  if(dp[bw][v] >= 0) return dp[bw][v];
  uint64_t ret = 1;
  for(int i = 0; i < G[v].size(); ++i) {
    int c = G[v][i];
    if(c == p) continue;
    uint64_t tmp = (uint64_t)calc(0, c, v);
    if(bw == 0) tmp = (tmp + calc(1, c, v))%MOD;
    ret = ret*tmp%MOD;
  }
  return dp[bw][v] = ret;
}


int main() {
  std::cin >> N;
  for(int i = 0; i < N-1; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);
  }
  for(int i = 0; i < 2; ++i) for(int j = 0; j < N; ++j) dp[i][j] = -1;
  std::cout << (calc(0, 0, -1) + calc(1, 0, -1))%MOD << std::endl;
  return 0;
}


Measured memory_bytes: 15616
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
if k==1:
    print(0)
else:
    X=[]
    A.sort()
    x=sum(A[k-1:])
    y=sum(A[:n-k+1])
    for i in range(k,n+1):
        X.append(x-y)
        x-=A[i-1]
        y-=A[n-i]

    ans=0
    cmb=1
    for i in range(k-2,n-1):
        ans+=cmb*X[i-(k-2)]
        ans%=mod
        cmb*=(i+1)*pow(i-(k-3),mod-2,mod)
        cmb%=mod
    print(ans)

Measured memory_bytes: 14416
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

answer=0
for x in 0..(X/500)
  if x > A
    break
  end
    for y in 0..((X-500*x)/100)
    if y > B
      break
    end
    p = (X-500*x-100*y)/50
    if p < 0
      break
    end
    if p <= C
      answer += 1
    end
  end
end

puts(answer)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << A.at(N - 1) - A.at(0) << endl;
    return 0;
}

Measured memory_bytes: 3648
var
n,m,i,j,k,t,x,y:longint;
a:array[0..101,0..101] of char;
 b:array[0..101,0..101] of longint;
begin
read(n,m);
readln;
for i:= 1 to n do
begin
for  j:= 1 to m do
begin
read(a[i,j]);
if a[i,j]='#' then begin inc(b[i-1,j]); inc(b[i-1,j-1]);
                               inc(b[i+1,j]); inc(b[i+1,j+1]);
                               inc(b[i-1,j+1]); inc(b[i+1,j-1]);
                               inc(b[i,j+1]); inc(b[i,j-1]);
                      end;
end;
readln;
end;
for i:= 1 to n do
 begin
  for j:= 1 to m do
 if a[i,j]='#' then write('#')
                 else write(b[i,j]);
writeln;
 end;
end.

Measured memory_bytes: 128
N = input()
N = int(N)
x = []
v = []
Y = 0
for i in range(N):
    X,V = input().split()
    x.append(X)
    v.append(V)
for i in range(N):
    if v[i] == 'JPY':
        Y += int(x[i])
    elif v[i] == 'BTC':
        Y += 380000.0 * float(x[i])
print(Y)

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

#同じ行、列で2回押すのはノーカウントにできる
#行、列で押した回数を独立にできる
#nのうちp、mのうちq押す
#p*m+q*n-p*q
cnt=0
for p in range(n+1):
    for q in range(m+1):
        if p*m+q*n-2*p*q==k:
            cnt+=1
if cnt>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

n, m, k = map(int, input().split())
L = UnionFind(n)
F = [0] * n
B = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    F[a] += 1
    F[b] += 1
    L.union(a, b)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if L.same(c, d):
        B[c] += 1
        B[d] += 1

for i in range(n):
    print(L.size(i) - F[i] - B[i] - 1)

Measured memory_bytes: 93784
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    using P = tuple<int, int>;
    vector<P> p = {P(a % 2, -a), P(b % 2, -b), P(c % 2, -c)};
    sort(p.begin(), p.end());
    int64_t x, y, h;
    tie(h, ignore) = p[0];
    tie(ignore, x) = p[1];
    tie(ignore, y) = p[2];

    cout << h * x * y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};

#define N 1000
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  int a[n];
  REP(i,n){
    cin >> a[i];
  }
  sort(a, a+n);

  REP(i, m){
    int b,c; cin >> b >> c;
    vecp.push_back(P(c,b));
  }
  sort(vecp.begin(), vecp.end(), std::greater<P>());
  int j=0;
  for(auto& v: vecp){
    for(int k=0; k < v.second; k++){
      if (j >= n) break;
      if (a[j] < v.first){
        a[j] = v.first;
        j++;
      }else{
        break;
      }
    }
  }
  
  ll sum =0;
  REP(i,n){
    sum+=a[i];
  }
  cout << sum;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int d;
  cin >> d;
  string s = "Christmas";
  string e = " Eve";
  rep(i, 25-d) s += e;
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3552
function Main(input){
  var inputArray = input.split('');
  var sum = 0;

  for(var i = 0 ; i < inputArray.length ; i++){
    sum += Number(inputArray[i]);
  }

  if(sum % 9  === 0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

using namespace std;

int main() {
	int N;
	cin >> N;
	unordered_map<string, int> S;
	for (int i = 0; i < N; i++) {
		string str;
		cin >> str;
		S[str]++;
	}

	int max = 0;
	for (auto itr = S.begin(); itr != S.end(); ++itr) {
		if (max < itr->second)max = itr->second;
	}

	vector<string> ans;
	for (auto itr = S.begin(); itr != S.end(); ++itr) {
		if (max == itr->second)ans.push_back(itr->first);
	}

	sort(ans.begin(), ans.end());

	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;



}

Measured memory_bytes: 26692
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678];
signed main() {
	vector<ll> v; map<ll, ll> cost;
	ll n, m, a, b, c, x, cnt = 0, ans = 0; string s, t, u;
	cin >> s >> t >> u;
	if (s[s.size() - 1] == t[0] && t[t.size() - 1] == u[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll M_MAX = 100000;

ll N, M;

vector<ll> table;


void input() {
	scanf("%lld%lld", &N, &M);
	table=vector<ll>(N+1,0);
}

void solve() {
	ll ans = 0;

	//for (int i = 0; i < T; i++) table[i] = 0;
	for (ll i = 0; i < M; i++) {
		ll a,b;
		cin >> a>> b;
		a--;
		table[a]++;  // 入店処理: カウントを 1 増やす
		table[b]--;  // 出店処理: カウントを 1 減らす
	}
	
	// シミュレート
	for (ll i = 0; i < N; i++) {
		if (0 < i) table[i] += table[i - 1];
	}
	debug(table);
	// 最大値を調べる
	for (ll i = 0; i < N; i++) {
		if(table[i]==M)ans++;
	}

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

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;
vector<pair<int,int> > ps[20];

int main(void) {
  int n;
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    REP(j, a) {
      int x, y;
      cin >> x >> y;
      --x;
      ps[i].push_back(make_pair(x, y));
    }
  }
  int res = 0;
  REP(pat, 1 << n) {
    int cnt = __builtin_popcount(pat);
    if(cnt <= res) {
      continue;
    }
    REP(i, n) {
      if(pat & (1 << i)) {
        for(auto p : ps[i]) {
          if(p.second != ((pat >> p.first) & 1)) {
            goto NEXT;
          }
        }
      }
    }
    res = cnt;
  NEXT:
    ;
  }
  cout << res << endl;
  return 0;
}


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

int main() {
    string S;
    string T;
    int count=0;
    cin >> S >> T;
    for(int i=0;i<S.length();i++){
        char c = S[i];
        char d = T[i];
        if(c!=d){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3916
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){
	int x,y;scanf("%d%d",&x,&y);
	if(x<=9&&y<=9)return printf("%d\n",x*y),0;
	puts("-1");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int num(int p,int x){
    if(p==1)return 1;//0 included
    if(x==-1){
        int sum=num(p-1,-1);
        for(int i=1;i<=9;i++)sum+=num(p-1,i);
        return sum;
    }
    if(x==0)return (num(p-1,0)+num(p-1,1));
    if(x==9)return (num(p-1,9)+num(p-1,8));
    return (num(p-1,x+1)+num(p-1,x)+num(p-1,x-1));//2~8
}
int main() {
	int n,l=0,first=-1,mae;
	cin>>n;
	for(int i=10;i>0;i--){//keta
	    if(first==-1){//null
	        if(l+num(i,-1)<=n){
                l+=num(i,-1);
                first=0;
	        }
	    }
	    if(first==0){//konoketa dewa aru
	        for(int j=1;j<=9;j++){//sonoketano number
	            if(l+num(i,j)>n){
	                cout<<j;
	                first=j;
	                mae=first;
	                   break;
    	        }
    	        else {
	                l+=num(i,j);
	            }
	        }
	    }
	    else if(first>0){
	        for(int j=max(mae-1,0);j<=min(mae+1,9);j++){//sonoketano number
	            if(l+num(i,j)>n){
	                cout<<j;
	                mae=j;
	                   break;
    	        }
    	        else {
	                l+=num(i,j);
	                //cout<<endl<<l<<' ';
	            }
	        }
	    }
	}
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, raw_input().split())

c = 0
d = 0
for i in range(1, N + 1):
	if i % K == 0:
		c += 1
	elif K % 2 == 0 and i % K == K / 2:
		d += 1
print c ** 3 + d ** 3


Measured memory_bytes: 8964
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

ll arr[200005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	vector<ll>L,R;
	ll l=0,r=0;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			if(l!=0)
			{
				L.eb(l);
				l=0;
			}
			r++;
		}
		else
		{
			if(r!=0)
			{
				R.eb(r);
				r=0;
			}
			l++;
		}
	}
		if(l!=0)
			{
				L.eb(l);
				l=0;
			}
				if(r!=0)
			{
				R.eb(r);
				r=0;
			}
    ll die=0;
	for(ll i=0;i<s.size();i++)
	{
	    if(s[i]=='R' && s[i+1]=='L')
	    {
	        ll valr=R[die];
	        ll vall=L[die];
	        die++;
	        ll valu=valr+vall;
	        if(valu%2==0)
	        {
	            cout<<valu/2<<" "<<valu/2<<" ";
	        }
	        else
	        {
	            if(valr%2==0)
	            {
	                 cout<<valu/2<<" "<<valu/2+1<<" ";
	            }
	            else
	            {
	                 cout<<valu/2+1<<" "<<valu/2<<" ";
	            }
	        }
	        i++;
	    }
	    else
	    {
	        cout<<0<<" ";
	    }
	}
    return 0;
}


//252908XL

Measured memory_bytes: 1604
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;

int main() {
    IO;
    int n;
    cin >> n;
    int cnt[20][20]; ll ans=0;
    memset(cnt, 0, sizeof (cnt));
    forr(i,1,n) {
        string tmp = to_string(i);
        int f = tmp[0] - '0';
        int l = tmp.back() - '0';
        cnt[f][l]++;
    }
    forr(i,1,n) {
        string tmp = to_string(i);
        int f = tmp[0] - '0';
        int l =tmp.back() - '0';
        ans += cnt[l][f];
        string r = tmp;
        reverse(all(r));
    }

    cout << ans;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string s;

	cin>>s;
	int ans = 0;
	for (size_t i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - 1 - i]) {
			ans += 1;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations

N,K = map(int,input().split())

if (N-2)*(N-1) < 2*K:
    print(-1)
else:
    print(N-1 + (N-2)*(N-1)//2 - K)

    for i in range(2,N+1):
        print(1, i)

    for _,(i,j) in zip(range((N-2)*(N-1)//2 - K), combinations(range(2,N+1), 2)):
        print(i,j)

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=true;
/*---------------------------------------------------*/

pair<double,string> data[55];

void mysort(int n){
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1;j++){
      if(data[j].first<data[j+1].first)swap(data[j],data[j+1]);
      else if(data[j].first==data[j+1].first&&data[j].second>data[j+1].second)swap(data[j],data[j+1]);
    }
  }
}


int main(){
  int n;
  double p,a,b,c,e,d,f,s,m;
  while(cin>>n){
    if(n==0)break;
    rep(i,n){
      cin>>data[i].second>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      data[i].first=((f*m*s)-p)/(a+b+c+(d+e)*m);
    }
    mysort(n);
    //rep(i,n)cout<<data[i].first<<endl;
    rep(i,n)cout<<data[i].second<<endl;
    cout<<"#"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		int x = 1 << M;
		int ans = (100 * (N - M) + 1900 * M) * x;
		printf("%d\n", ans);
	}
	return 0;
}


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

int main(){
	int N,T,A;
	cin>>N>>T>>A;
	float sa;
	int H;
	int index;
	cin>>H;
	sa=abs(A-(T-H*0.006));
	index=1;
	for (int i=2;i<=N;++i){
		cin>>H;
		if (sa>abs(A-(T-H*0.006))) {
			sa=abs(A-(T-H*0.006));
			index=i;
		}
	}
	cout<<index<<endl;
}


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

vector<vector<int>> g;
int d[222222], e[222222];
void f(int u, int v) {
    d[v] = -1 - d[u];
    for(int w : g[v])
        if(w != u)
            f(v, w);
}
int main() {
    int n;
    cin >> n;
    g.resize(n + 1);
    for(int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    f(0, 1);
    int k = 0;
    for(int i = 1; i <= n; i++)
        if(d[i])
            k++;
    if(k <= n / 3) {
        int j = 0;
        for(int i = 1; i <= n && j + 3 <= n; i++)
            if(d[i])
                d[i] = j += 3, e[j] = 1;
        j = 1;
        for(int i = 1; i <= n; i++) {
            if(d[i] > 0)
                continue;
            while(e[j])
                j++;
            d[i] = j++;
        }
        for(int i = 1; i <= n; i++)
            cout << d[i] << ' ';
        cout << endl;
        return 0;
    }
    if(n - k <= n / 3) {
        int j = 0;
        for(int i = 1; i <= n && j + 3 <= n; i++)
            if(!d[i])
                d[i] = j += 3, e[j] = 1;
        j = 1;
        for(int i = 1; i <= n; i++) {
            if(d[i] > 0)
                continue;
            while(e[j])
                j++;
            d[i] = j++;
        }
        for(int i = 1; i <= n; i++)
            cout << d[i] << ' ';
        cout << endl;
        return 0;
    }
    int j = -2;
    for(int i = 1; i <= n && j + 3 <= n; i++)
        if(d[i])
            d[i] = j += 3, e[j] = 1;
    j = -1;
    for(int i = 1; i <= n && j + 3 <= n; i++)
        if(!d[i])
            d[i] = j += 3, e[j] = 1;
    j = 1;
    for(int i = 1; i <= n; i++) {
        if(d[i] > 0)
            continue;
        while(e[j])
            j++;
        d[i] = j++;
    }
    for(int i = 1; i <= n; i++)
        cout << d[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    rep(i,n) {
        repr(j,i+1,n-1) {
            if (l[i]==l[j]) continue;
            int k=lower_bound(l.begin(),l.end(),l[i]+l[j])-upper_bound(l.begin(),l.end(),l[j]);
            ans+=k;
        }
    }
    cout << ans << endl;
     
    return 0;   
}

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

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(12) << w*h/2.0 << ' ';
    cout << ((x==w/2&&y==h/2)?1:0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    double a1,b1;
    a1 = a;
    b1 = b;
    printf("%d %d %.5f\n",(a/b),(a%b),(a1/b1));
    return 0;
    
}


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

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b;
char l;
cin >> a >> l >> b;
(l == '+') ? cout << a + b << "\n" : cout << a - b << "\n"; 
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,b;
int mx,mn=INF;
int main(){
	for(int i=1;i<6;i++)cin>>x,mx=max(mx,x),mn=min(mn,x);
	cin>>b;
	if(mx-mn<=b)puts("Yay!");
	else puts(":(");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

L n,m;
double d;
int main()
{
    cin>>n>>d;
    m=d*100+.01;
    n=(n*m)/100;
    cout<<n<<endl;
    return 0;
}

/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3692
#include <iostream>

using namespace std;

int s = 1,x;

bool panduan(int a,int b,int c){
	x = a;
	while(s <= b){
		if(a % b == c)return true;
		a = x;
		s++;
		a *= s;
	}
	return false;
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(panduan(a,b,c))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
lst = list(range(1, n + 1))
perm = list(itertools.permutations(lst, n))
ans = 0

for i in range(len(perm)):
    if perm[i] == p:
        ans += i
    if perm[i] == q:
        ans -= i

print(abs(ans))

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
typedef long long ll;

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

    bool flg = true;

    for (int i = 0; i < s.length(); i++)
    {
        if((i+1) % 2 != 0){
            if(s[i] == 'L'){
                flg = false;
                break;
            }
        }else{
            if(s[i] == 'R'){
                flg = false;
                break;
            }
        }
    }

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

    }

    // cout << fixed;
    // cout << setprecision(10);

    // if (x >= a * a * b / 2)
    // {

    //     cout << atan(2 * (pow(a, 2) * b - x) / pow(a, 3) )* 180 / M_PI << endl;
    // }
    // else
    // {
    //     cout << atan(a * b * b / (2 * x)) * 180 / M_PI << endl;
    // }

    // ll answer = 1;

    // ll last = n;

    // for (ll i = 1; i < n; i++)
    // {
    //     if (i > last || i * i > n)
    //     {
    //         break;
    //     }

    //     if (n % i == 0)
    //     {
    //         if (i < n - i)
    //         {
    //             answer = (i - 1) + (n / i - 1);
    //             last = n / i;
    //         }
    //         else
    //         {
    //             break;
    //         }
    //     }
    // }

    // cout << answer << endl;

    // bool flg = false;

    // for (int i = 1; i <= 9; i++)
    // {
    //     if (n % i == 0)
    //     {
    //         if ((n / i) >= 1 && (n / i) <= 9)
    //         {
    //             flg = true;
    //             break;
    //         }
    //     }
    // }

    // if (!flg)
    // {
    //     cout << "No" << endl;
    // }
    // else
    // {
    //     cout << "Yes" << endl;
    // }

    // for (int i = 0; i < n; i++)
    // {
    //     cin >> a[i];
    // }

    // vector<ll> a;
    // for (int i = 0; i < n; i++)
    // {
    //     int j;
    //     cin >> j;
    //     a.push_back(j);
    // }

    //sort(a,a+n); ソート
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long t[100005],dp[100005];
int n;
int main(){
cin>>n;
for(int i=2;n+1>=i;i++)
	cin>>t[i];
	dp[2]=0;
	dp[3]=abs(t[3]-t[2]);
for(int i=4;n+1>=i;i++)
	dp[i]=min(dp[i-1]+abs(t[i]-t[i-1]),dp[i-2]+abs(t[i]-t[i-2]));
cout<<dp[n+1];
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int gcd(int x, int y){
	while (y){
		x %= y;
		swap(x, y);
	}
	return x;
}

const int mod = 1000000007;

long long pw(long long a, long long b){
	long long res = 1;
	while (b){
		if (b & 1ll)
			res = res * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

const int N = 5555;

int ways[N][N];
int last[N][N];

int main(){

	ways[0][0] = 1;
	for (int i = 1; i < N - 10; i++){
		for (int j = i % 2; j <= i; j += 2){
			if (j == 0)
				ways[i][j] = ways[i - 1][j + 1];
			else
				ways[i][j] = (ways[i - 1][j - 1] + ways[i - 1][j + 1]) % mod;
		}
	}

	last[0][0] = 1;
	for (int i = 1; i < N - 10; i++){
		for (int j = 1; j <= i; j++){
			last[i][j] = (last[i - 1][j - 1] * 2ll + last[i - 1][j + 1]) % mod;
		}
		last[i][0] = (last[i - 1][0] + last[i - 1][1]) % mod;
	}
	// cerr << last[2][0] << "\n";

	int n = nxt();
	string s;
	cin >> s;
	int k = s.length();

	long long ans = 0;
	for (int i = 0; i <= n - k; i++){
		ans += 1ll * last[i][0] * ways[n - 1 - i][k - 1] % mod * pw(2, (n - i - k) / 2) % mod;
		// cerr << ans << "\n";
	}

	cout << ans % mod << "\n";

	return 0;
}


Measured memory_bytes: 160768
#include <bits/stdc++.h>
 using namespace std;
 int main(int argc, char const *argv[])
 {
 	int n,res=0;
    cin>>n;
    vector<int> C(n-1),S(n-1),F(n-1);
    for(int i=0;i<n-1;i++)
      cin >> C.at(i) >> S.at(i) >> F.at(i);
    for(int i=0;i<n;i++)
        {  
		 int t = 0;
            for(int j=i;j<n-1;j++)
               {
				 if( t < S.at(j)) {
                    t = S[j];
                }
                else if( t % F.at(j) == 0)
                       { /* just ignore it and do nothing */ }
                     else {
                        t += F.at(j) - (t % F.at(j));
                     }
                      t += C.at(j);
               }
        cout << t <<endl;
    }
 	return 0;
 }  

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

vector<long long> vi;

int main(){
    int n;
    scanf("%d",&n);
    long long sum=0;
    for(int i=0;i<n;i++){
        long long s;
        scanf("%lld",&s);
        vi.push_back(s);
        sum^=s;
    }
    for(int i=0;i<n;i++){
        printf("%lld ",sum^vi[i]);
    }
    return 0;
}


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

#define N 100010 

using namespace std;

int a[N], b[N], c[N];

int main() {
	int n;
	cin >> n ;
	for (int i = 1; i <= n; i ++ ) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i ++ ) {
		scanf("%d", &b[i]);
	}
	for (int i = 1; i < n; i ++ ) {
		scanf("%d", &c[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++ ) {
		ans += b[a[i]];
	}
	for (int i = 2; i <= n; i ++ ) {
		if (a[i] == a[i - 1] + 1) {
			ans += c[a[i] - 1];
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
int main(){
    scanf("%lld",&a);
    b=1;c=0;
    while (a){
        c+=b;
        a/=2;
        b*=2;
    }
    printf("%lld",c);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    string s,t;
    int n,m;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    vector<vector<int>> dp(n+1,vector<int> (m+1));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            dp[i][j]=max({dp[i-1][j],dp[i][j-1],dp[i][j]});
        }
    }
    string ans="";
    int row=n,col=m;
    while(row !=0 && col!=0){
        debug(row,col);
        if(s[row-1]==t[col-1]){
            if(dp[row][col]==dp[row-1][col-1]+1){
                ans+=s[row-1];
                row=row-1;
                col=col-1;
                continue;
            }
        }
        else if(dp[row][col]==dp[row-1][col]){
            row=row-1;
        }
        else if(dp[row][col]==dp[row][col-1]){
            col=col-1;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 38536
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = 700;
        for (char s : sc.next().toCharArray()) {
            if (s == 'o') price += 100;
        }
        System.out.println(price);
    }

}

Measured memory_bytes: 20564
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	int l=0,r=1e9;
	while(r-l>1){
		int mid=(l+r)/2;
		debug(mid);
		int cnt=0;
		REP(i,n) cnt+=(a[i]-1)/mid;
		debug(cnt);
		if(cnt>k) l=mid;
		else r=mid;
	}
	
	cout<<r<<endl;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int a = s.nextInt();
			int b = s.nextInt();
			int aa = a;
			int bb = b;
			while (true) {
				if (a < b) {
					int t = a;
					a = b;
					b = t;
				}
				if(a%b == 0)break;
				a = a%b;
			}
			bb/=b;
			System.out.println(b+" "+(aa*bb));
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  n+=2;
  vector<int> a(n);
  rep(i,n) R a[i];
  pr(max(abs(a[1]-a[n-1]),abs(a[n-2]-a[n-1])));
}

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readInt()
  val P = readInts()

  var pMin = Int.MAX_VALUE
  var cnt = 0
  for (i in 0 until N) {
    val p = P[i]
    if (pMin > p) {
      pMin = p
      cnt++
    }
  }

  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int a, b;
  char op;
  std::cin >> a >> op >> b;
  if (op == '+')
    print(a + b);
  else if (op == '-')
    print(a - b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    string s,t="";
    cin>>s;
    reverse(s.begin(), s.end());
    
    string str[4]={"dream", "dreamer", "erase", "eraser"};
    for(int i=0;i<4;i++){
        reverse(str[i].begin(), str[i].end());
    }
    int i=0;
    bool flag=true;
    for(int i=0;i<s.size();){
        bool flag2=false;
        for(int j=0;j<4;j++){
            string d=str[j];
            if(s.substr(i, d.size()) == d){
                flag2=true;
                i+=d.size();
            }
        }
        if(!flag2){
            flag=false;
            break;
        }
    }
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
#include <iomanip>
/*--------------------------hbp16@hbp16-Inspiron-3543:-$------------------------------*/
int main(int argc, char const *argv[])
{
    double n;
    cin>>n;
    cout<<setprecision(12)<<fixed<<pow(n/3,3); 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    ll n;
    cin >> n;
    ll cost[2][3];
    rep(i, 2) rep(j, 3) cin >> cost[i][j];
    vector<ll> dp1(n + 1, n);
    rep(i, 3) rep(j, n + 1 - cost[0][i])
        chmax(dp1[j + cost[0][i]], dp1[j] + cost[1][i] - cost[0][i]);
    ll m = dp1[n];
    vector<ll> dp2(m + 1, m);
    rep(i, 3) rep(j, m + 1 - cost[1][i])
        chmax(dp2[j + cost[1][i]], dp2[j] + cost[0][i] - cost[1][i]);
    cout << dp2[m] << endl;

    return 0;
}

Measured memory_bytes: 195584
x,n = map(int, input().split())
p = list(map(int, input().split()))

if n==0:
    print(x)
    exit()

mindiff = 10*10
ans=-1
for i in range(-10,200):
    if i in p:
        continue
    if abs(i - x) < mindiff:
        ans = i
        mindiff = abs(i-x)
print(ans)

Measured memory_bytes: 61660
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [[0] for _ in range(N+1)]
cnt = 0
for _ in range(M):
    a, b = map(int, input().split())
    l[a].append(H[b-1])
    l[b].append(H[a-1])
for i in range(1, N+1):
    if H[i-1] > max(l[i]):
        cnt += 1
print(cnt)

Measured memory_bytes: 95804