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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    double m[n][n];
    pair<double, double> d[n];
    rep(i, n) cin >> d[i].first >> d[i].second;

    rep(i, n)
    {
        rep(j, n)
        {
            m[i][j] = sqrt(pow((d[i].first - d[j].first), 2) + pow((d[i].second - d[j].second), 2));
        }
    }

    vector<int> v(n);
    iota(ALL(v), 0);
    double sum = 0;

    do
    {
        rep(i, n - 1) sum += m[v[i]][v[i + 1]];
    } while (next_permutation(ALL(v)));

    double t = 1;
    for (int i = 1; i <= n; i++)
        t *= i;

    printf("%.10f", sum / t);

    return 0;
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll a,b,q;
  cin >> a >> b >> q;
  
  vector<ll> s(a, 0);
  for(ll i=0;i<a;i++){
    cin >> s[i];
  }
  
  vector<ll> t(b,0);
  for(ll i=0;i<b;i++){
    cin >> t[i];
  }

  ll x;
  for(ll i=0;i<q;i++){
    cin >> x;
    ll sC[2], tC[2];
    auto sIter = lower_bound(s.begin(),s.end(),x);
    auto sPrevIter = sIter; sPrevIter--;

    if(sIter == s.end()){
      sIter = s.end()-1;
      sPrevIter = s.end()-1;
    }
    if(sIter == s.begin()){
      sPrevIter = s.begin();
    }
    sC[0] = *sPrevIter;
    sC[1] = *sIter;

    auto tIter = lower_bound(t.begin(),t.end(),x);
    auto tPrevIter = tIter; tPrevIter--;
    if(tIter == t.end()){
      tIter = t.end()-1;
      tPrevIter = t.end()-1;
    }
    if(tIter == t.begin()){
      tPrevIter = t.begin();
    }
    tC[0] = *tPrevIter;
    tC[1] = *tIter;
    
    ll minMove = 100000000000000;
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        ll move = 0;
        move = abs(x-sC[j])+abs(sC[j]-tC[k]);
        move = min(move,abs(x-tC[k])+abs(sC[j]-tC[k]));
        minMove = min(minMove,move);
      }
    }
    cout << minMove << endl;
  }
  return 0;
}



Measured memory_bytes: 4884
def maxof(x, y)
    return (x > y) ? x : y
end

def minof(x, y)
    return (x < y) ? x : y
end

ans = 1

N = gets.to_i
T = gets.split(" ").map(&:to_i)
A = gets.split(" ").map(&:to_i)

Ts = Array.new(N){Array.new(2)}
As = Array.new(N){Array.new(2)}

for i in 0..N-1 do
	if i == 0 then
		Ts[i][0] = T[i]
		Ts[i][1] = T[i]
	else
		if T[i-1] != T[i] then
			Ts[i][0] = T[i]
			Ts[i][1] = T[i]
		else
			Ts[i][0] = 1
			Ts[i][1] = T[i]
		end
	end
end

for i in 0..N-1 do
	if i == N-1 then
		As[i][0] = A[i]
		As[i][1] = A[i]
	else
		if A[i+1] != A[i] then
			As[i][0] = A[i]
			As[i][1] = A[i]
		else
			As[i][0] = 1
			As[i][1] = A[i]
		end
	end
end

for i in 0..N-1 do
	if Ts[i][0] > As[i][1] || Ts[i][1] < As[i][0] then
		ans = 0
	else
		ans = ans * (minof(Ts[i][1],As[i][1]) - maxof(Ts[i][0],As[i][0]) + 1) % (10**9 + 7)
	end
end

p ans


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int N;
	cin >> N;
	int ans = 1;
	for (int i = 1; i < 10; i++) {
		if (pow(2, i) <= N) ans = pow(2, i);
		else break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}



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

    LL n, k; cin >> n >> k;
    LL arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    
// 	for (int i = 0; i < n; i++){
// 	    for (int j = 0; j <= k; j++) dp[i][j] = 0;
// 	}

    if (k == 0){
        cout << 1 << endl;
        return 0;
    }
    vector<vector<LL> > dp(n, vector<LL>(k + 1));
    
	for (int i = 0; i <= min(arr[0],k); i++) dp[0][i] = 1;
	for (int i = 1; i <= k; i++) dp[0][i] += dp[0][i - 1];

	for (LL i = 1; i < n; i++){
		dp[i].resize(k + 1, 0);
		for (LL j = 0; j <= k; j++){
			int mn = max(0LL, j - arr[i]);
			dp[i][j] = dp[i - 1][j];
			if (mn != 0){
				dp[i][j] = (dp[i][j] - dp[i - 1][mn - 1] + MOD) % MOD;
			}
		}
		for (int j = 1; j <= k; j++) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
	}

    // for (int i = 0; i < n; i++){
    //     for (int j = 1; j <= k; j++){
    //         cout << dp[i][j] - dp[i][j - 1] << " ";
    //     }
    //     cout << endl;
    // }
    
    LL ans = (dp[n - 1][k] + MOD - dp[n - 1][k - 1]) % MOD;
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 79488
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

ll repeat_squaring(ll N, ll P, ll M){
	if(P==0) return 1;
	if(P%2==0){
		ll t = repeat_squaring(N, P/2, M);
		return t*t %M;
	}

	return (N * repeat_squaring(N, P-1, M)) % M;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	ll n, a, b;
	ll mod = 1000000007;
	cin >> n >> a >> b;

	ll ans = repeat_squaring(2, n, mod) - 1;

	ll fac_a = 1;
	for(int i = n; i > n-a; i--){
		fac_a = fac_a * i % mod;
	}
	ll y_a = 1;
	for(int i = 1; i <= a; i++){
		y_a = y_a * i % mod;
	}

	ll fac_b = 1;
	for(int i = n; i > n-b; i--){
		fac_b = fac_b * i % mod;
	}
	ll y_b = 1;
	for(int i = 1; i <=b; i++){
		y_b = y_b * i % mod;
	}
	y_a = repeat_squaring(y_a, mod-2, mod);
	ans -= (fac_a * y_a) % mod;
	y_b = repeat_squaring(y_b, mod-2, mod);
	ans -= (fac_b * y_b) % mod;

	while(ans < 0){
		ans += mod;
	}
    cout <<ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#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;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;

signed main(){
    int H; cin>>H;
    int h = H; int k=0;
    while(h>0){
        h /=2;
        k++;
    }
    int ans=0; int N=1;
    REP(i,k){
        ans += N;
        N *= 2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

result = 0

for i in range(n):
    if i == n-1:
        if x == a[n-1]:
            result += 1
    else:
        x -= a[i]
        if x < 0:
            break
        else:
            result += 1
print(result)

Measured memory_bytes: 3060
a,b = map(int,input().split())
a1=-1
for i in range(1,100000):
    k = i*(0.08)
    j = i*(0.1)
    if int(k)==a and int(j)==b:
        a1=i
        break
if a1!=-1:
    print(a1)
else:
    print("-1")


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"
#define MOD 1000000000+7

#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

int f(int n, int x) {
  if (n == -1) return 0;
  else return n / x + 1;
}

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int w, a, b; cin >> w >> a >> b;

  if (a == b) {
    num = 0;
  }
  else if (a < b) {
    if (b <= a + w ) num = 0;
    else num = b - (a + w);
  } else { // b < a
    if (a <= b + w) num = 0;
    else num = a - (b + w);
  }

  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # 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):
        # 2つの木をマージする。
        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 are_same(self, x, y):
        # 2つの要素の根が同じかどうかを調べる
        return self.find(x) == self.find(y)

    def members(self, x):
        # xと同じ根の要素をリストで出力
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == self.n]

    def roots(self):
        # 根である要素をリストで出力
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{} {}".format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
for v in uf.parents:
    if v < 0:
        ans = max(ans, abs(v))
print(ans)

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
ll a, b;
ll gcd(ll x, ll y)
{
    if (y==0) return x;
    return gcd(y, x%y);
}
int main()
{
    cin >> a >> b;
    ll g = gcd(a, b);
    ll ans = 1;
    if (g % 2 == 0)
    {
        ans++;
        while (g % 2 == 0) g /= 2;
    }
    for (ll i=3; i*i<=g; i+=2)
    {
        if (g % i == 0)
        {
            ans++;
            while (g % i == 0) g /= i;
        }
        if (g == 1)
        {
            break;
        }
    }
    if (g != 1) ans++;
    cout << ans << endl;
}


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

#define sz size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 1e6 + 9;
const int inf = 1e9 + 7;

int n, k;
int a[N], dp[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>> n>> k;
    for(int i = 1; i <= n; i++){
        cin>> a[i];
        dp[i] = inf;
    }
    dp[1] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k && i + j <= n; j++){
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
        }
    }
    cout<< dp[n];
}


Measured memory_bytes: 4736
N, M = map(int, input().split())
A = []
B = []
C = []
flag = 0

for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())

for i in range(N- M+ 1):
  for j in range(N- M+ 1):
    C = []
    for k in range(M):
      C.append(A[j+ k][i:i+ M])
    if(B == C):
      print("Yes")
      flag = 1
      break
  if(flag == 1):
    break
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
void swap(int& x, int& y){
    int tmp = x;
    x=y;
    y=tmp;
}
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
     
    cout << a << " " << b << " "  << c << endl;
}


Measured memory_bytes: 3068
# 全部やる
import numpy as np
import itertools
N,D = map(int,input().split())
X = [np.array(input().split(), dtype=np.int64) for _ in range(N)]

answer = 0
for u,v in itertools.combinations(X,2):
  d = ((u-v) * (u-v)).sum()
  dd = int(round(d**.5))
  if d == dd*dd:
    answer += 1

print(answer)

Measured memory_bytes: 12480
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        
        int ans = 0;
        for (int i = a; i <= t; i+= a) {
            ans += b;
        }
        
        System.out.println(ans);
    }
}


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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n-1);
    std::vector<int> buka(n+1, 0);

    for(int i = 0; i < n-1; i++){
        std::cin >> a[i];
    }

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

    for(int i = 1; i <= n; i++){
        std::cout << buka[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;



int main(){
    ll n;
    cin >> n;
    string s = "";
    while (n){
        if (n%26==0){
            s += 'z';
            n--;
        }
        else s += (char) ((n%26)-1) + 'a';
        n/=26;
    }
    reverse(s.begin(), s.end());
    cout << s;
    
}

Measured memory_bytes: 3128
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void Main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] > a[i]) {
			ans += a[i-1] - a[i];
			a[i] += a[i-1] - a[i];
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main()
{
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	int dp[n];
	for(int i=0;i<n;i++)
	{
		dp[i]=MOD;
	}
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		if(i+j<n) dp[i+j] = std::min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
	//	cout<<"dp["<<i+1<<"]="<<dp[i+1]<<"\n";
	//	if(i+2<n) dp[i+2] = std::min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	//	cout<<"dp["<<i+2<<"]="<<dp[i+2]<<"\n";
	}
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  double x;
  cin >> x;

  ll ans = 0;
  ll cnt = 100;
  while(cnt < x){
    cnt *= 1.01;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main()
{ 
  int a[6];
  int pos;
  for(int i=1;i<=5;i++)
  {
    cin>>a[i];
    if(a[i]==0)
    {
      pos=i;
    }
  }
  
  cout<<pos<<endl;

}

Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    pii a[100010];
    int v[100010];
    int cnt[100010] = {};
    map<int, int> m, m2;
    int idx = 0;
    rep(i,0,n) v[i] = INF;
    rep(i,0,n) {
        int inp;
        cin >> inp;
        a[i] = pii(inp, i);
    }
    sort(a, a+n);
    rep(i,0,n) {
        if(!m2.count(a[i].fr)) {
            v[idx] = min(v[idx], a[i].sc);
            cnt[idx]++;
            m[idx] = a[i].fr;
            m2[ a[i].fr ] = idx++;
        }
        else {
            v[ m2[a[i].fr] ] = min(v[ m2[a[i].fr] ], a[i].sc);
            cnt[ m2[a[i].fr] ]++;
        }
    }
    int ans[100010] = {};
    idx--;
    while(idx != -1) {
        int mi = v[idx], sz = cnt[idx];
        // printf("idx = %lld, val = %lld, mi = %lld, sz = %lld\n", idx, m[idx], mi, sz);
        int sum, diff;
        if(idx != 0) {
            diff = m[idx] - m[idx-1];
            sum = sz * diff;
        }
        else {
            diff = m[idx];
            sum = sz * diff;
        }
        ans[mi] += sum;

        if(idx != 0) {
            v[idx-1] = min(v[idx-1], v[idx]);
            cnt[idx-1] += cnt[idx];
        }
        idx--;
    }
    rep(i,0,n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 17408
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b;
	c=a+b;
	int num=c.length();
	long long number=0;
	for(int i=0;i<num;i++){
		number=number*10+(c[i]-'0');
	}
	int ss=sqrt(number);
	if(ss*ss==number){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
//	cout<<ss;
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := 700 + strings.Count(s,"o")*100
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >>n;
    vector<int> A(5,0);
    REP(i,n){
        string s;
        cin >> s;
        if(s[0]=='M')A[0]++;
        if(s[0]=='A')A[1]++;
        if(s[0]=='R')A[2]++;
        if(s[0]=='C')A[3]++;
        if(s[0]=='H')A[4]++;
    }
    ll ans=0;
    for(int mask=0; mask < (1<<5); mask++){
        int bit=0;
        REP(i,5) if(mask>>i & 1) bit++;
        if(bit!=3) continue;
        ll tmp=1;
        REP(i,5) if(mask>>i & 1) tmp*=A[i];
        ans+=tmp;
        debug(tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <queue>
#include <set>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

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

struct S {
    int x, y, d;
    S() {}
    S(int x, int y, int d) : x(x), y(y), d(d) {}
};

inline int sig(const S& s) {
    return (s.x<<8) | (s.y<<2) | s.d;
}

inline int sig(const pair<S, S>& p) {
    return (sig(p.first) << 16) | sig(p.second);
}

bool operator<(const S& l, const S& r) {
    if (l.x != r.x) return l.x < r.x;
    if (l.y != r.y) return l.y < r.y;
    return l.d < r.d;
}

int H, W;
char f[16][64];

S forward(int x, int y, int d) {
    for (;;) {
        const int nx = x + dx[d], ny = y + dy[d];
        if (f[nx][ny] == '#') return S(x, y, d);
        x = nx, y = ny;
    }
}

#define PUSH(q, vis, s) { \
    const int si = sig(s); \
    if (!vis.count(si)) vis.insert(si), q.push(s); \
}

bool reach(const S& s, const S& t) {
    set<int> vis;
    queue<S> q;
    const S st = forward(s.x, s.y, s.d);
    PUSH(q, vis, st);
    while (!q.empty()) {
        const S cur = q.front();
        q.pop();
        if (cur.x == t.x && cur.y == t.y) return true;
        int dd = 1;
        rep (_, 2) {
            const S p = forward(cur.x, cur.y, (cur.d+dd)%4);
            PUSH(q, vis, p);
            dd += 2;
        }
    }
    return false;
}

void push(queue<pair<S, S> >& q, set<int>& vis, const S& l, int x, int y, int d) {
    const int rd = (d+2) % 4;
    if (f[x+dx[d]][y+dy[d]] != '#') return ;
    for (;;) {
        const pair<S, S> ss(l, S(x, y, d));
        PUSH(q, vis, ss);
        const int nx = x + dx[rd], ny = y + dy[rd];
        if (f[nx][ny] == '#') break;
        x = nx, y = ny;
    }
}

bool accomplish(const S& s, const S& t) {
    set<int> vis;
    queue<pair<S, S> > q;
    const S st = forward(s.x, s.y, s.d);
    rep (d, 4) push(q, vis, st, s.x, s.y, d);
    while (!q.empty()) {
        const pair<S, S> vv = q.front();
        q.pop();
        const S cur = vv.first, rev = vv.second;
        if (cur.x == t.x && cur.y == t.y
                && rev.x == t.x && rev.y == t.y && rev.d == t.d) {
            return true;
        }
        int dd = 1;
        rep (_, 2) {
            push(q, vis, forward(cur.x, cur.y, (cur.d+dd)%4),
                    rev.x, rev.y, (rev.d+dd)%4);
            dd += 2;
        }
    }
    return false;
}

void solve() {
    S s(-1, -1, -1), t(-1, -1, -1);
    rep (i, H) rep (j, W) if (f[i][j] == 'K') {
        f[i][j] = '.';
        s.x = i, s.y = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') s.d = d;
    }
    rep (i, H) rep (j, W) if (f[i][j] == 'M') {
        f[i][j] = '.';
        t.x = i, t.y = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') t.d = d;
    }
    if (!reach(s, t)) puts("He cannot bring tea to his master.");
    else if (!accomplish(s, t)) puts("He cannot return to the kitchen.");
    else puts("He can accomplish his mission.");
}

int main() {
    for (;;) {
        scanf("%d%d", &W, &H);
        if (H == 0) return 0;
        rep (i, H) rep (j, W) scanf(" %c", f[i]+j);
        solve();
    }
}

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

using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{	
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];
	for (int i = 1; i < n; ++i)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 1940
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int array[] = new int[3];
        int sum=0;

        for(int i = 0; i<3; i++){
            array[i] = sc.nextInt();
        }

        Arrays.sort(array);

        sum = array[0]+array[1];
        System.out.println(sum);
    }

}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<utility>
#include<string>
#include<queue>
using namespace std;

#define rep(i,n) for(int i=0; i<n;i++)
typedef  pair<int,int> pii;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int main(){
    int w,h;
    while(cin>>w>>h,w+h){
        vector<vector<bool> >black(51,vector<bool>(51,true));
        vector<vector<bool> >white(51,vector<bool>(51,true));
        vector<pii>b,wh;
        vector<vector<char>>v(51,vector<char>(51));
        rep(i,h)rep(j,w){
            cin>>v[i][j];
            if(v[i][j]=='W')wh.push_back(pii(i,j));
            if(v[i][j]=='B')b.push_back(pii(i,j));
        }
        queue<pii>que;
        rep(i,wh.size())que.push(wh[i]);
        while(!que.empty()){
            pii now=que.front(); que.pop();
            rep(i,4){
                int nx=now.second+dx[i];
                int ny=now.first+dy[i];
                if(0<=nx&&nx<w&&0<=ny&&ny<h){
                    if(v[ny][nx]!='.'||white[ny][nx]==false)continue;
                    white[ny][nx]=false;
                    que.push(pii(ny,nx));
                }
            }
        }
        rep(i,b.size())que.push(b[i]);
        while(!que.empty()){
            pii now=que.front(); que.pop();
            rep(i,4){
                int nx=now.second+dx[i];
                int ny=now.first+dy[i];
                if(0<=nx&&nx<w&&0<=ny&&ny<h){
                    if(v[ny][nx]!='.'||black[ny][nx]==false)continue;
                    black[ny][nx]=false;
                    que.push(pii(ny,nx));
                }
            }
        }
        int bl=0,whi=0;
        rep(i,h)rep(j,w){
            if(white[i][j]==false&&black[i][j]==true)whi++;
            if(white[i][j]==true&&black[i][j]==false)bl++;
        }
        cout<<bl<<" "<<whi<<endl;
    }
}

Measured memory_bytes: 3136
A,B,C,X,Y = list(map(int,input().split(" ")))

total=0
total2=0
if A+B>2*C:
    total+=2*C*min(X,Y)
    if X>Y:
        total+=(X-Y)*A
    else:
        total+=(Y-X)*B
    total2+=2*C*max(X,Y)
else:
    total = X*A+Y*B
    print(total)
    exit()
print(min(total,total2))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
#ARC077C
import sys
import math

n=int(input())

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))


ans=[]
if(n%2==0):
	for i in range(0,n//2):
		ans.append(hoge[n-i*2-1])
	for i in range(0,n//2):
		ans.append(hoge[i*2])
else:
	for i in range(0,n//2+1):
		ans.append(hoge[n-i*2-1])
	for i in range(0,n//2):
		ans.append(hoge[i*2+1])
	

ret=""
ret+=str(ans[0])
for i in range(1,n):
	ret+=" "
	ret+=str(ans[i])
print(ret)


Measured memory_bytes: 32576
#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> P;
const int INF = 1e9;

int main(){
	int n; 
	cin >> n;
	int a = (n + 1) / 2;
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	uint64_t N;
	uint64_t tmp;
	uint64_t min = UINT64_MAX;

	cin >> N;

	int sqrt_N = (int)sqrt(N);
	for (int i = 1; i <= sqrt_N; i++) {
		if (N % i == 0) {
			tmp = N / i + i - 2;
			
			if (min > tmp) {
				min = tmp;
			}
		}
	}

	cout << min << endl;

	return 0;
}

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

using namespace std;

int main(void){
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++) cout << "#";
  cout << "\n";
  for(int i = 0; i < H; i++){
    string a;
    cin >> a;
    cout << "#" << a << "#" << "\n";
  }
  for(int i = 0; i < W + 2; i++) cout << "#";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define Next(a,i) ((i)+1)%(a).size()
#define Curr(a,i) (i)%(a).size()
#define Prev(a, i) (i+a.size()-1) % a.size()

using namespace std;

int main(void){

  int n,m,x,dp[101][101];
  vector<int>a;

  cin >> n;

  while(n--){
    a.clear();

    for(int i=0;i<101;i++)
      for(int j=0;j<101;j++)dp[i][j]=0;

    cin >> m;
    for(int i=0;i<m;i++){
      cin >> x;
      a.push_back(x);
    }
    
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	for(int k=0;k<i;k++){
	  dp[Curr(a,j)][Curr(a,i)]=max(dp[j][i],dp[Curr(a,j)][Curr(a,k)]+dp[Next(a,j+k)][Prev(a,i-k)]+abs(curr(a,j)-next(a,j+k))); 
	}
      }
    }
    int ans=0;
    for(int i=0;i<m;i++)
      for(int j=0;j<m;j++)
      ans=max(ans,dp[i][j]);
    
    cout << ans << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=15;
int n,m,nm;
int v[N][N];
int C[N][N],invC[N][N];
void prework(){
	For(i,0,nm){
		C[i][0]=invC[i][0]=1;
		For(j,1,i){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			invC[i][j]=Pow(C[i][j],mod-2);
		}
	}
}
int f[N][N][3],g[N][N][3];
int res[N][N];
int main(){
	n=read(),m=read(),nm=max(n,m);
	For(i,0,n-1){
		string s;
		cin>>s;
		For(j,0,m-1)
			v[i][j]=s[j]=='#';
	}
	prework();
	int ans=1<<n;
	For(i,0,n-1)
		Add(f[n-i][m][2],((LL)C[n][i]<<i)%mod);
	Fod(i,n,1)
		Fod(j,m,1){
			Add(res[i][j],f[i][j][1]);
			Add(res[i][j],f[i][j][2]);
			For(k,1,j-1){
				Add(g[i][j-k][1],(LL)f[i][j][2]*2*C[j][k]%mod);
				Add(g[i][j-k][1],(LL)f[i][j][1]*C[j][k]%mod);
				Add(g[i][j-k][2],(LL)f[i][j][2]*((1<<k)-2)%mod*C[j][k]%mod);
			}
			Add(ans,(LL)f[i][j][2]*((1<<j)-2)%mod);
			/********************************/
			Add(res[i][j],g[i][j][1]);
			Add(res[i][j],g[i][j][2]);
			For(k,1,i-1){
				Add(f[i-k][j][1],(LL)g[i][j][2]*2*C[i][k]%mod);
				Add(f[i-k][j][1],(LL)g[i][j][1]*C[i][k]%mod);
				Add(f[i-k][j][2],(LL)g[i][j][2]*((1<<k)-2)%mod*C[i][k]%mod);
			}
			Add(ans,(LL)g[i][j][2]*((1<<i)-2)%mod);
		}
	For(a,1,(1<<n)-1)
		For(b,1,(1<<m)-1){
			int flag=1;
			int x=0,y=0;
			For(i,0,n-1){
				if (~a>>i&1)
					continue;
				x++;
				vi c(2,0);
				For(j,0,m-1)
					if (b>>j&1)
						c[v[i][j]]++;
				if (!c[0]||!c[1])
					flag=0;
			}
			if (!flag)
				continue;
			For(j,0,m-1){
				if (~b>>j&1)
					continue;
				y++;
				vi c(2,0);
				For(i,0,n-1)
					if (a>>i&1)
						c[v[i][j]]++;
				if (!c[0]||!c[1])
					flag=0;
			}
			if (!flag)
				continue;
			Add(ans,(LL)res[x][y]*invC[n][x]%mod*invC[m][y]%mod);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <functional>
#include <cmath>
#define REP(i,n) for(lint i{}, i##_len=(n); i<i##_len; ++i)
#define DOUBLE_LOOP(i, h, j, w) for(lint i{}; i < (lint)(h); ++i)for(lint j{}; j < (lint)(w); ++j)
#define DOUBLE_LOOP2(i, j, n) for(lint i{}; i < (lint)(n - 1); ++i)for(lint j{i + 1}; j < (lint)(n); ++j)
#define SZ(x) ((lint)(x).size())
using lint = long long; lint N, H, W;
using namespace std;
const long long INF{ 1LL << 60 };
const long double PI{ 3.1415926535897932 };
const long long NUM97{ 1000000007 };
template<class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return 1; } return 0; }
template<class T> inline bool chmin(T& x, T y) { if (x > y) { x = y; return 1; } return 0; }
std::vector<std::string> field;
std::vector<std::vector<bool>> seen(H, std::vector<bool>(W));
const std::vector<int> dx { 1, 0, -1, 0 };
const std::vector<int> dy { 0, 1, 0, -1 };
std::vector<lint> dp;
std::vector<lint> h;
int main(){
	std::cin >> N;
	h.resize(N); for(auto& r : h) std::cin >> r;
	dp.resize(N);  for (auto& r : dp) r = INF;
	dp[0] = 0;
	for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + std::abs(h[i] - h[i - 1]));
		if (i > 1) { chmin(dp[i], dp[i - 2] + std::abs(h[i] - h[i - 2])); }
	}
	std::cout << dp[N - 1] << std::endl;
	return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>
#include<set>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	string S;
	cin >> S;
	if (S == "Sunny")cout << "Cloudy";
	else if (S == "Cloudy")cout << "Rainy";
	else cout << "Sunny";
}

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

const int N = (int) 5e2 + 5;

int n, m, q;
int edge[N][N], dp[N][N];

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d %d %d", &n, &m, &q);
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d %d", &u, &v);
		edge[u][v]++;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) dp[i][j + 1] = dp[i][j] + edge[i][j];
	while (q--) {
		int u, v; scanf("%d %d", &u, &v);
		int res = 0;
		for (int i = u; i <= v; i++) res += (dp[i][v + 1] - dp[i][u]);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));
  int now=1;
  bool c=1;
  int g=0;
  if(n%2!=0){
    if(a[0]==0){
      now=2;
      g++;
    }else{
      cout<<0<<endl;
      return 0;
    }
  }
  for(int i=g;i<n;i++){
    if(c){
      if(a[i]==now)
      c=0;
      else{
        cout<<0<<endl;
        return 0;
      }
    }else{
      if(a[i]==now){
        c=1;
        now+=2;
      }else{
        cout<<0<<endl;
        return 0;
      }
    }
  }

  ll ans=1;
  rep(i,n/2){
    ans*=2;
    ans%=mod;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		System.out.println((s[0]==t[0] ? 1 : 0)+(s[1]==t[1] ? 1 : 0)+(s[2]==t[2] ? 1 : 0));
	}
}


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

int main()
{
  int N,A;
  int count=30,counta=0;
  
  cin >> N;
  
  for(int i=0;i<N;i++)
  {
    counta = 0;

    cin >> A;
    while(A%2==0)
    {
      A /= 2;
      counta += 1;
    }

    if (counta < count)
      count = counta;
  }

  cout << count;
}

Measured memory_bytes: 256
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}
// number {{{
#define SIZE 100005
#define MOD  1000000007LL

// べき乗
// verified AOJ NTL_1_B
ll pow(ll a, ll b) {
    if(b == 0) return 1;
    ll aa = pow(a, b/2);
    return aa*aa%MOD*(b%2 == 1 ? a : 1)%MOD;
}

// 階乗と階乗の逆元
// ARC077D
ll fact[SIZE] = {1, 1};
ll finv[SIZE] = {1, 1};

void initFact() {
    // fact
    for(ll i=2;i<SIZE;i++){
        fact[i] = fact[i-1]*i%MOD;
    }

    // finv
    finv[SIZE-1] = pow(fact[SIZE-1], MOD-2);
    for(ll i=SIZE-1;i>=3;i--){
        finv[i-1] = finv[i]*i%MOD;
    }
}

// 組み合わせの数
// ARC077D
ll comb(int n, int r) {
    if(r > n) return 0;
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

// 最小公約数
ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}

// 素数判定 (エラトステネスのふるい)
bool isPrime[SIZE];
void initIsPrime() {
    for(int i=0;i<SIZE;i++){
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=2;i*i<=SIZE;i++){
        if(isPrime[i]){
            for(int j=i*i;j*j<=SIZE;j+=i){
                isPrime[j] = false;
            }
        }
    }
}

// 素因数分解
// verified AOJ NTL_1_A
vector<pair<int, int>> factor(int n) {
    vector<pair<int, int>> ret;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            int count = 0;
            while(n%i == 0){
                count++;
                n /= i;
            }
            if(count > 0){
                ret.push_back({i, count});
            }
        }
    }
    if(n != 1){
        ret.push_back({n, 1});
    }
    return ret;
}
//}}}

int main() {
    initFact();
    initIsPrime();

    int n;cin >> n;

    map<int, ll> m;

    for(int i=1;i<=n;i++){
        auto f = factor(i);
        for(auto ff : f){
            if(m.find(ff.first) == m.end()){
                m[ff.first] = 0;
            }
            m[ff.first] += ff.second;
        }
    }

    ll ans = 1;
    for(auto mm : m){
        ans = ans*(mm.second+1) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long k = Long.parseLong(in.next());
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());

            if (b - a <= 2) {
                out.println(k + 1);
            } else {
                long bis = 1;
                bis += (a - 1);
                k -= a - 1;
                bis += k / 2 * (b - a);
                k = k % 2;
                bis += k;
                // 出力
                out.println(bis);
            }

        }

    }
}



Measured memory_bytes: 35844
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(" ");

			int[] cards = new int[10];
			for (int i = 0; i < cards.length; i++) {
				cards[i] = 1;
			}
			int c0 = Integer.parseInt(nico[0]);
			int c1 = Integer.parseInt(nico[1]);
			int c2 = Integer.parseInt(nico[2]);

			cards[c0 - 1] = 0;
			cards[c1 - 1] = 0;
			cards[c2 - 1] = 0;
			
			int rest = 20 - c0 - c1;
			
			int p = 0;
			for (int i = 0; i < cards.length; i++) {
				if ((cards[i] == 1) && ((i + 1) > rest)) p++;
			}
			
			if ((p / 7.0) * ((p - 1) / 6.0) + ((7 - p) / 7.0) * (p / 6.0) > 0.5) System.out.println("NO");
			else System.out.println("YES");
		}
	}
}

Measured memory_bytes: 25772
#include<stdio.h>

int calc_gcd (int a,int b);


int main (void){

    int a, b;
    int gcd;
    int lcm;

    while(scanf("%d %d",&a ,&b) != EOF){

        if(a > b){
            gcd = calc_gcd(a, b);
        }else if(b > a){
            gcd = calc_gcd(b, a);
        }else if(a == b){
            gcd = a;
        }

        lcm = a / gcd * b;

        printf("%d %d\n",gcd ,lcm);
    }
    return 0;
}


int calc_gcd (a, b){

    int x, y, z;

    while(1){
            x = a;
            y = b;
            z = x % y;

            if(z != 0){
                a = y;
                b = z;
            }else if(z == 0){
                return y;
            }
    }

}

Measured memory_bytes: 592