akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};

int main() {
  string s; cin >>s;
  rep(i, s.size()) if (s[i] == '?') s[i] = 'D';
  cout <<s <<endl;
}


Measured memory_bytes: 3756
n, m = gets.chomp.split.map(&:to_i)

h = []
n.times do |i|
  h[i] = []
end

u = []
n.times do |i|
  u[i] = []
end

m.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  a -= 1
  b -= 1
  h[a].push(b)
  h[b].push(a)
  u[i] = [a, b]
end

ans = 0

def go?(a, hh, gone)
  gone[a] = true
  hh[a].each do |e|
    go?(e, hh, gone) unless gone[e]
  end
  gone.all?
end

m.times do |i|
  a, b = u[i]
  h[a].delete(b)
  h[b].delete(a)

  # a→bに行けるか
  gone = Array.new(n, false)
  ans += 1 unless go?(a, h, gone)

  # 戻す
  h[a].push(b)
  h[b].push(a)
end

p ans

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,l,a[202],awm=0;
	cin>>n;
	for(i=0;i<n*2;i++) cin>>a[i];
	sort(a,a+i);
	for(i=0;i<n*2;i=i+2) awm=awm+a[i];
	cout<<awm;
	return 0;
/* TODO (#1#): m416 */
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define int long long
int dsum(long long n) {
  int s = 0;
  while (n) s += n%10, n/=10;
  return s;
}

long long f(int S, long long X) {
  for (int n=0; n<=15; n++) {
    long long rest = X;
    rep(_, n) rest /= 10;
    if (rest%10 == 9) continue;
    rest++;
    int nokori = 9-(rest%10);
    rep(_, n) rest *= 10;
    int s = S - dsum(rest);
    if (s < 0) continue;
    long long r = 1;
    rep(_, n) {
      int g = min(s, 9LL);
      rest += r*g;
      s -= g;
      r *= 10;
    }
    if (s > nokori) continue;
    rest += r*s;
    //cout<<"f("<<S<<","<<X<<")="<<rest<<"\n";
    return rest;
  }
  //cout<<"f("<<S<<","<<X<<")=inf\n";
  return 1e16;
}

int K;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K;
  long long cur = 0;
  rep(_, K) {
    pair<double, long long> m = make_pair(1e16, -1);
    for (int s=1; s<=150; s++) {
      long long cand = f(s, cur);
      m = min(m, make_pair((double)cand/(double)s, cand));
    }
    cur = m._2;
    cout << cur << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
    int a,b,c,x,count=0;

	scanf("%d %d %d", &a, &b, &c);
	for(x=a; x<=b; x++)
	{
		if(c % x == 0)
		{
			count++;
		}
	}
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

ans = A*(N//(A+B))
N -= (A+B)*(N//(A+B))
ans += min(A, N)
print(ans)

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

vector<ll> m,C;
vector<int> V;
vector<vector<int>> c;

void rec(int i=0){
    C[i]=m[i];
    for(auto j:c[i]){
        rec(j);
        C[i]+=C[j];
        V[i]+=V[j];
    }
}

template< typename T, typename Compare = greater< T > >
vector< T > knapsack_limitations(const vector< int > &w, const vector< int > &m, const vector< T > &v,
                                 const int &W, const T &NG, const Compare &comp = Compare()) {
    const int N = (int) w.size();
    vector< T > dp(W + 1, NG), deqv(W + 1);
    dp[0] = T();
    vector< int > deq(W + 1);
    for(int i = 0; i < N; i++) {
        for(int a = 0; a < w[i]; a++) {
            int s = 0, t = 0;
            for(int j = 0; w[i] * j + a <= W; j++) {
                if(dp[w[i] * j + a] != NG) {
                    auto val = dp[w[i] * j + a] - j * v[i];
                    while(s < t && comp(val, deqv[t - 1])) --t;
                    deq[t] = j;
                    deqv[t++] = val;
                }
                if(s < t) {
                    dp[j * w[i] + a] = deqv[s] + j * v[i];
                    if(deq[s] == j - m[i]) ++s;
                }
            }
        }
    }
    return dp;
}


template <class T>
T knapsack_limitations(const vector< T > &w, const vector< T > &m, const vector< int > &v,
                       const T &W) {
    const int N = (int) w.size();
    auto v_max = *max_element(begin(v), end(v));
    if(v_max == 0) return 0;
    vector< int > ma(N);
    vector< T > mb(N);
    for(int i = 0; i < N; i++) {
        ma[i] = min< T >(m[i], v_max - 1);
        mb[i] = m[i] - ma[i];
    }
    T sum = 0;
    for(int i = 0; i < N; i++) sum += ma[i] * v[i];
    auto dp = knapsack_limitations(v, ma, w, sum, T(-1), less<>());
    vector< int > ord(N);
    iota(begin(ord), end(ord), 0);
    sort(begin(ord), end(ord), [&](int a, int b) {
        return v[a] * w[b] > v[b] * w[a];
    });
    T ret = T();
    for(int i = 0; i < dp.size(); i++) {
        if(dp[i] > W || dp[i] == -1) continue;
        T rest = W - dp[i], cost = i;
        for(auto &p : ord) {
            auto get = min(mb[p], rest / w[p]);
            if(get == 0) continue;
            cost += get * v[p];
            rest -= get * w[p];
        }
        ret = max(ret, cost);
    }
    return ret;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    ll x,d;
    in>>x>>d;
    m.resize(n);
    vector<int> p(n);
    c.resize(n);
    in>>m[0];
    p[0]=-1;
    Fr(i,n-1){
        in>>m[i]>>p[i];
        c[--p[i]].emplace_back(i);
    }
    V.resize(n,1);
    C.resize(n);
    vector<ll> M(n,d);
    M[0]=1e9;
    rec();
    cout<<knapsack_limitations(C,M,V,x)<<endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int A, B;
    cin >> A >> B;
    if(B%A == 0){
        cout << A+B << endl;
    }
    else cout << B - A << endl;
    return 0;
}

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

N, K = map(int, input().split())
p = list(map(int, input().split()))
a = [(pi+1)/2 for pi in p]
acc = [0]

for ai in a:
    acc.append(acc[-1]+ai)
    
ans = 0

for i in range(N-K+1):
    ans = max(ans, acc[i+K]-acc[i])

print(ans)

Measured memory_bytes: 77812
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n = I()
G = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = LI()
    G[a - 1] += [(i, b - 1)]
    G[b - 1] += [(i, a - 1)]


k = 0
for i in G:
    k = max(k, len(i))


col_set = set(range(1, k + 1))
ans = [0] * (n - 1)
visited = [0] * n
visited[0] = 1
dq = deque([(0, 0)])
while dq:
    u, pre_col = dq.popleft()
    col = 1
    for i, v in G[u]:
        if not visited[v]:
            visited[v] = 1
            if pre_col == col:
                col += 1
            ans[i] = col
            dq += [(v, col)]
            col += 1


print(k)
for j in ans:
    print(j)










Measured memory_bytes: 70688
S=input()
if(S=="SUN"):
    print(7)
elif(S=="MON"):
    print(6)
elif(S=="TUE"):
    print(5)
elif(S=="WED"):
    print(4)
elif(S=="THU"):
    print(3)
elif(S=="FRI"):
    print(2)
elif(S=="SAT"):
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i+=2){
        int divisor = 0;
        for(int j = 1; j <= i; j++){
            if(i%j == 0){divisor++;}
        }
        if(divisor == 8){ans++;}
    }
    cout << ans << endl;
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 100'000 + 6;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 n;
    cin >> n;

    //while (n / 10 > 0) {
    //    n /= 10;
    //}

    n %= 10;

    map<i64, string> q = {
        { 0, "pon" },
        { 1, "pon" },
        { 6, "pon" },
        { 8, "pon" },

        { 2, "hon" },
        { 4, "hon" },
        { 5, "hon" },
        { 7, "hon" },
        { 9, "hon" },

        { 3, "bon" },
    };

    cout << q[n] << endl;

    
    return 0;
}

Measured memory_bytes: 3648
def bit_patterns(n):
  if n <= 0:
    return []
  
  patterns = [[0],[1]]
  for i in range(n - 1):
    grow = []
    for pattern in patterns:
      #print(pattern)
      for b in range(2):
        clone = pattern[:]
        clone.append(b)
        grow.append(clone)
    patterns = grow  
  #print(patterns)    
  return patterns


def main():
  lights = []
  #スイッチ個数、電球個数を取得
  n, m = [int(val) for val in input().split()]
  #print(n, m)
  #各電球のスイッチへの接続状態を取得
  for i in range(m):
    #一番目はスイッチ個数だが配列長を見ればよいので捨てる。
    #0スタートにしたいので1引く
    lights.append([int(val) - 1 for val in input().split()][1:]) 

  #点灯条件 pi を取得
  pis = [int(val) for val in input().split()]

  #スイッチの全パターン2^nを順次テストしてすべて点灯するパターンを数える
  all_count = 0
  patterns = bit_patterns(n)
  #print(patterns)
  for pattern in patterns:
    on_count = 0
    for li in range(len(lights)):
      light = lights[li]
      pi = pis[li]
      
      switch_count = 0
      for si in light:
        switch_count += pattern[si]
      if switch_count % 2 == pi:
        on_count += 1
    if on_count == m:
      all_count += 1
  print(all_count)
  
main()

Measured memory_bytes: 3316
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr ll INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

const int MAX_N = 200010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD-2);
    }
}

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

    calc(200005);

    ll n, a, b, c; cin>>n>>a>>b>>c;

    ll ans = 0;
    for(ll i=n; i<=2*n-1; i++){
        ll child = (modpow(a, n) * modpow(b, i - n) % MOD + modpow(a, i - n) * modpow(b, n) % MOD) * i * 100 % MOD;
        ll mother = modpow(a + b, i) * (100 - c) % MOD;
        (ans += comb(i - 1, n - 1) * child % MOD * modpow(mother, MOD - 2)) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int xzero[11];
int yzero[11];
int x[11];
int y[11];

void f(int *a, int *b, int m) {
    for(int i = 1; i <= m; i++) {
        swap(a[i], b[i]);
        b[i] = -b[i];
    }
}

void g(int *a, int *b, int m) {
    for(int i = 2; i <= m; i++) {
        a[i] -= a[1];
        b[i] -= b[1];
    }
    a[1] = 0;
    b[1] = 0;
    while(a[2] <= 0) f(a, b, m);
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int m0;
        cin >> m0;
        for(int i = 1; i <= m0; i++) {
            cin >> xzero[i] >> yzero[i];
        }
        for(int i = 2; i <= m0; i++) {
            xzero[i] -= xzero[1];
            yzero[i] -= yzero[1];
        }
        xzero[1] = 0;
        yzero[1] = 0;
        while(xzero[2] <= 0) f(xzero, yzero, m0);
        for(int index = 1; index <= n; index++) {
            int m;
            cin >> m;
            for(int i = 1; i <= m; i++) {
                cin >> x[i] >> y[i];
            }
            if(m != m0) continue;
            bool ok = true;
            g(x, y, m);
            for(int i = 1; i <= m; i++) {
                if(x[i] != xzero[i] || y[i] != yzero[i]) ok = false;
            }
            if(ok) {
                cout << index << endl;
                continue;
            }
            ok = true;
            for(int i = 1; i <= m - i + 1; i++) {
                swap(x[i], x[m - i + 1]);
                swap(y[i], y[m - i + 1]);
            }
            g(x, y, m);
            for(int i = 1; i <= m; i++) {
                if(x[i] != xzero[i] || y[i] != yzero[i]) ok = false;
            }
            if(ok) {
                cout << index << endl;
                continue;
            }
        }
        cout << "+++++" << endl;
    }
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;

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

    vector<int64_t> cost(n, 0);
    for(int i = 1; i < n; i++) {
        int64_t cost_min = 1e9;
        for(int j = 1; j <= min(i, k); j++) {
            int64_t cost_candidate = cost[i - j] + abs(h[i] - h[i - j]);
            if(cost_min > cost_candidate) {
                cost_min = cost_candidate;
            }
        }
        cost[i] = cost_min;
    }

    // for(int i = 0; i < n; i++) cout << cost[i] << ' ';
    // cout << endl;

    cout << cost[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int a[n];
		int b[n];
		int c[n];
		int s=0;
		rep(i,n) cin>>a[i];
		rep(i,n) cin>>b[i];
		rep(i,n) {if(i==0) continue; cin>>c[i];}
		rep(i,n) {
			s+=b[a[i]-1];
			if(i==0) continue;
			if(a[i]==a[i-1]+1 ){
				s+=c[a[i]-1];
			}

		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(e, i) for (auto e: i)
#define all(x) x.begin(), x.end()


using namespace std;
const int maxn = 105;
const int inf = 0x3f3f3f3f;
typedef long long ll;


int main() {
#ifdef AZUKI_LOCAL
    freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif
    int k;
    cin >> k;
    ll ans = 0;
    for (ll i = 1; i < k+1; ++i) {
        ll x = (i+k-(k%i)) * (k/i) / 2;
        ans += x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  int h,w,x,y,r;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    vector<vector<int>> dp((1<<N)+5, vector<int>(55, INF));
    dp[0][0] = 0;
    REP(bits, 1<<N){
        int cnt = __builtin_popcount(bits);
        vector<pair<int,int>> rem;
        int rem_cnt = cnt;
        REP(i,N) if(!((bits >> i) & 1)) rem.emplace_back(i, rem_cnt++);
        REP(i,51){
            if(dp[bits][i] == INF) continue;
            for(auto x : rem){
                int next;
                if(abs(cnt - x.first) % 2 == 0) next = A[x.first];
                else next = B[x.first];

                if(next >= i) chmin(dp[bits|(1<<x.first)][next], dp[bits][i] + abs(x.second - cnt));
            }
        }
    }
    int ans = INF;
    REP(i,51) chmin(ans, dp[(1<<N)-1][i]);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 67840
#include<bits/stdc++.h>
using namespace std;
#define ll long long 

// C
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll i;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n/2]-a[(n/2)-1];
}

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

int main()
{
	int n,i,mx=0,mn=10000000,count=0;
	cin>>n;
	vector<int>a(n),cnt(1000001,0);
	bool res[1000001];
	memset(res,false,1000001);
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		res[a[i]]=true;
		cnt[a[i]]++;
		mx=max(mx,a[i]);
		mn=min(mn,a[i]);
	}
//	cout<<mx<<mn;
	sort(a.begin(),a.end());
	for(i=0;i<n;i++)
	{
//		cout<<a[i]<<endl;
		for(int j=a[i]*2;j<=mx;j=j+a[i]) res[j]=false;
	}
	for(i=0;i<=mx;i++)
		if(res[i] && cnt[i]<=1) count++;
	if(mn==mx) count=0;
	if(n==1) count=1;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 8976
while s = gets
  break if s.nil? || s.chomp == ''

  d = s.split(',').map(&:to_f)
  v1, v2 = d.pop(2)
  d1 = v1 * d.inject(:+) / (v1 + v2) 

  p, r = 0, 0
  d.each_with_index { |d,i|
    p += d
    if p >= d1
      r = i + 1 
      break
    end 
  }

  puts r
end

Measured memory_bytes: 2380
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,K;
  cin>>n>>K;  
  int ans = 0;

  auto calc =[&](int b){
    if(b <= K) return 0LL; 
    int num = b - K;
    int res = (n / b) * num;
    res += max(0LL,n % b - K + (K!=0));
    return res;
  };

  for(int i=1;i<=n;i++){
    ans += calc(i);
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$N = $in->nextInt();
$P = $in->nextInt();

$A = [];
$allEven = true;
for ($i = 0;$i < $N;$i++) {
	$A[] = $in->nextInt();
	if ($A[$i] % 2 == 1) {
		$allEven = false;
	}
}

if ($allEven) {
	if ($P === 0) {
		$out->println(1 << $N);
	} else {
		$out->println(0);
	}
	return;
}

$ans = 1 << ($N - 1);

$out->println($ans);

?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;cin >> n;
    string s;cin >>s;
    int c=1;char k=s[0];
    for (int i=1;i<n;i++){
        if (s[i] != k) {
            c ++; k=s[i];
        }
    }
    cout << c <<"\n";
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
string a, b;
Int r[216000], l[216000];
vector<Int> cnt[216000];
Int calcr(Int x){
  Int res = n*2;
  Int base = 0;
  for(Int i = 0;i < n;i++){
    if(a[i] == b[(i+x)%n])continue;
    base++;
    if(r[i] <= x)continue;
    cnt[l[i]].push_back(r[i]-x);
  }
  Int rr = 0;
  for(Int i = n;i >= 0;i--){
    res = min(res, i + i + x + rr + rr);
    for(Int c:cnt[i]){
      rr = max(rr, c);
    }
    cnt[i].clear();
  }
  return res + base;
}


Int calcl(Int x){
  Int res = n*2;
  Int base = 0;
  for(Int i = 0;i < n;i++){
    if(a[i] == b[(i+n-x)%n])continue;
    base++;
    if(l[i] <= x)continue;
    cnt[r[i]].push_back(l[i]-x);
  }
  Int ll = 0;
  for(Int i = n;i >= 0;i--){
    res = min(res, i + i + x + ll + ll);
    for(Int c:cnt[i]){
      ll = max(ll, c);
    }
    cnt[i].clear();
  }
  return base + res;
}

int main(){
  cin >> a >> b;
  if(a == b){
    cout << 0 << endl;
    return 0;
  }
  n = a.size();
  bool noone = true;
  for(Int i = 0;i < n;i++)if(b[i] == '1')noone = false;
  if(noone){
    cout << -1 << endl;
    return 0;
  }

  for(Int i = 0;i < n;i++){
    while(b[(i + r[i]) % n] == '0')r[i]++;
    while(b[(i + n - l[i]) % n] == '0')l[i]++;
  }

  Int res = n*2;
  for(Int i = 0;i < n;i++){
    res = min(res, calcr(i));
    res = min(res, calcl(i));
  }

  cout << res << endl;
  
  return 0;
}

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

#define ll long long

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    if(b-a == c-b){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int r, c;
	cin >> r >> c;
	vector<vector<int>> a(r, vector<int>(c));
	rep(i, r) rep(j ,c) cin >> a[i][j];

	//縦
	vi colsum;
	rep(j, c)
	{
		int sum = 0;
		rep(i, r) sum += a[i][j];
		colsum.push_back(sum);
	}
	a.push_back(colsum);

	//横
	rep(i, r + 1)
	{
		int sum = 0;
		rep(j, c) sum += a[i][j];
		a[i].push_back(sum);
	}

	rep(i, r+1)
	{
		rep(j, c+1)
		{
			if(j == 0) cout << a[i][j];
			else cout << ' ' << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

#define INFLL 9999999999999999LL

int N,K;
vector<long long> H;
long long dp[333][333];

int main(){
	cin >> N >> K;
	H.push_back(0);
	for(int i=0;i<N;i++){
		long long h;
		cin >> h;
		H.push_back(h);
	}
	
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)dp[i][j]=INFLL;
	dp[0][0]=0;
	
	for(int i=1;i<=N;i++)for(int j=1;j<=i;j++){
		for(int k=0;k<i;k++){
			dp[i][j]=min(dp[i][j],dp[k][j-1]+max(0LL,H[i]-H[k]));
		}
	}
	
	long long ans=INFLL;
	for(int i=N-K;i<=N;i++)ans=min(ans,dp[i][N-K]);
	
	/*for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++)cout << dp[i][j] << " ";
		cout << endl;
	}*/
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

#define MAX_N 100000
#define INF 1000000000

struct uftree_w {
    int par[MAX_N], rank[MAX_N], w_dif[MAX_N]; //w_difは親との重みの差
    uftree_w(int N) {
        for (int i=0; i<N; i++) {
            par[i] = i;
            rank[i] = 0;
            w_dif[i] = 0;
        }
    }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            w_dif[x] += w_dif[par[x]];
            return par[x] = r;
        }
    }
    int weight(int x) {
        root(x); //経路圧縮
        return w_dif[x];
    }
    bool unite(int x, int y, int d) {
        d += weight(x) - weight(y); //根っこ同士をつなぐので
        x = root(x);
        y = root(y);
        if (x == y) return d == 0;
        if (rank[x] > rank[y]) {
            par[y] = x;
            w_dif[y] = d;
        } else {
            par[x] = y;
            w_dif[x] = -d;
            if (rank[x] == rank[y]) rank[y]++;
        }
        return true;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int N, M, L, R, D;
    scanf("%d %d", &N, &M);
    uftree_w line(N);
    for (int i=0; i<M; i++) {
        scanf("%d %d %d", &L, &R, &D);
        if (!line.unite(L-1, R-1, D)) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
//解説模写AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]){
    bool all_visited = true;
    rep(i,n){
        if(!visited[i]) all_visited = false;
    }
    
    if(all_visited) return 1;
    
    int ret = 0;
    
    rep(i,n){
        if(visited[i]) continue;
        if(!graph[v][i]) continue;
        
        visited[i] = true;
        ret += dfs(i,n,visited);
        visited[i] = false;
    }
    
    return ret;
}

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

    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }
    
    bool visited[nmax];
    rep(i,n) visited[i] = false;
    visited[0]  =true;
    
    cout << dfs(0, n, visited) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	int N;
	int[] a;
    public void solve() {
		a = new int[1000];
		
		while(true){
			
	        N = nextInt();
			
			if(N == 0)break;
			Arrays.fill(a,Integer.MAX_VALUE);
			for(int i = 0;i < N;i++){
				a[i] = nextInt();
			}
			
			Arrays.sort(a);
			
			int ans = Integer.MAX_VALUE;
			
			for(int i = 0;i < N - 1;i++){
				ans = Math.min(ans,a[i + 1] - a[i]);
			}
			out.println(ans);
		}
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }
 
    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }
 
    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }
 
    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
    public long nextLong() {
        return Long.parseLong(next());
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 30940
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,i;
	cin>>N;
	int dp[N];
	long long int A[N];
	long long int cost[N],j,k;
	for(i=0;i<N;i++)
	{
	cin>>A[i];
	}
	cost[0]=0;
	cost[1]=abs(A[1]-A[0]);
	if(N==2)
	cout<<cost[1];
	else
	{
		for(i=2;i<N;i++)
		{
			cost[i]=min((cost[i-1]+abs(A[i]-A[i-1])),(cost[i-2]+abs(A[i]-A[i-2])));
		}
		cout<<cost[N-1];
	}
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include<stdio.h>
#include <sstream>
#define pi 3.141592653589793238462
#define limit 100005
#define mo 1000000007;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli mod=9999999999999983;
lli primes[6]={1125899906842597,1495921043,1005985879,1495921043,1005985879,1495921043};
using namespace std;
vector<lli>adj[2000009];
lli parent[2000009];
lli vis[2000009];
lli level[2000009];
lli dist[2000009];
lli dp[100009];
lli arr[100009];
lli brr[2000009];
lli crr[2000009];
lli hashing[2000009];
lli ar[509][509];
lli br[509][509];
lli cr[509][509];
lli multiply(lli a,lli b){return ((a%mod)*(b%mod))%mod;}
lli add(lli a,lli b){return ((a%mod)+(b%mod))%mod;}
lli sub(lli a,lli b){return ((a%mod)-(b%mod)+mod)%mod;}
#define deb(x) cout<< #x << " " << x <<endl;
//deb(n);
vector<string>vect[200009];



lli power(lli x, lli y,lli p)
{
	lli res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=((res%p)*(x%p))%p;
		y=y>>1;
		x=((x%p)*(x%p))%p;
	}
	return res;
}


int main()
{
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int start_s = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    //vector< lli>vect,vt,vct;
    vector<lli>::iterator itt;
    set<lli>st;
    set<lli>::iterator itr;
    map<lli,lli>mp,mpp,mp1,mp2;
    map<lli,lli>::iterator it;

    lli i,j,k,n,m,res1,res2,q,t,a,b,c,maxi=INT_MIN,mini=INT_MAX,sum=0,ans=0,res=0,val=0,ans1=0,ans2=0,rem=0,diff=0,cnt=0,l,r,flag=0,e,index,val1=0,val2=0,z,h=0,u,v,mid,len,tot,fl=0;
    string str,str1,str2;
    lli ind;

    cin>>n>>m;


    for(i=1;i<=m;i++)
    {
        cin>>e;
        cin>>str;
        vect[e].push_back(str);
    }

    lli wa=0,ca=0;

    for(i=1;i<=n;i++)
    {
        cnt=0;
        flag=0;

        for(j=0;j<vect[i].size();j++)
        {
            if(vect[i][j]=="WA")
                cnt++;
            else
            {
                flag=1;
                ind=j;
                 break;
            }
        }


        if(flag==1)
        {
            ca+=1;
            wa+=cnt;
        }
    }

    cout<<ca<<" "<<wa<<endl;

}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] s = new String[n];

		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}

		Arrays.sort(s);

		for (int i = 0; i < n; i++) {
			System.out.print(s[i]);
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int w[200];

bool judge(int num, int length, int height){
	int count = 0;
	int sum = 0;
	for(int i = 0; i < length; i++){
		if(w[i] > num){
			return false;
		}
		if(sum + w[i] > num){
			count++;
			sum = w[i];
		}else{
			sum += w[i];
		}
	}
	count++;
	if(count <= height){
		return true;
	}
	return false;
}

int binary_search(int lef, int rig, int m, int n){
	int middle = (lef + rig) / 2;
	if(rig - lef <= 1){
		if(judge(lef, n, m)){
			return lef;
		}else{
			return rig;
		}
	}
	if(judge(middle, n, m)){
		rig = middle;
		return binary_search(lef, rig, m, n);
	}else{
		lef = middle;
		return binary_search(lef, rig, m, n);
	}
}

int main(){
	
	int m, n;
	
	while(true){
		
		cin >> m >> n;
		
		if(m == 0 && n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> w[i];
		}
		
		cout << binary_search(0, 1600000, m, n) << endl;
		
	}
	return 0;
}

Measured memory_bytes: 2964
#include<stdio.h>
int main(){
    int n;
    int cnt=0;
    char s[50];
    scanf("%d%s",&n,s);
    for(int i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
package main

import (
  "fmt"
  "sort"
)

func main() {
  var p, q, r int
  fmt.Scan(&p, &q, &r)
  num_list := []int{p,q,r}
  sort.Ints(num_list)
  ans:= num_list[0] + num_list[1]
  fmt.Println(ans)
  }

Measured memory_bytes: 512
(defun func (x y)
  (if x
	(+ (if (equal (car x) (car y))
				  0
				  1)
	   (func (cdr x) (cdr y)))
	0))


(setq a (concatenate 'list (read-line)))
(setq b (reverse a))

(princ (/ (func a b) 2))


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

 int main() {
   vector<char> S(3);
   for(int i = 0;i < 3; i++){
     cin >> S.at(i);
   }
   
   int a = 700;
   for(int i = 0;i < 3; i++){
     if(S.at(i) == 'o'){
       a += 100;
     }
   }
   cout << a << endl;
 }

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

int main()
{
   int n,m;
   cin >> n;
   map<string, int> mp;
   rep(i,n) 
   {
      string s;
      cin >> s;
      mp[s]++;
   }
   cin >> m;
   rep(i,m)
   {
      string t;
      cin >> t;
      mp[t]--;
   }
   int ans = 0;
   for(auto a : mp)
   {
      ans = max(ans, a.second);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=100005;
vector<int> v[nmax];
int viz[nmax],rep[nmax],lev[nmax],tt[nmax];
int a,b,n,m,i,j,nr,x;
void dfs(int x)
{
    viz[x]=1;
    for(int i=0;i<v[x].size();i++)
        if(!viz[v[x][i]])
           dfs(v[x][i]);
    rep[++nr]=x;
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    m=n-1+m;
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
    }
    for(int it=1;it<=n;it++)
    {
        if(!viz[it])
          dfs(it);
        //lev[it]=n+1;
    }
    for(int it=n;it>=1;it--)
    {
        x=rep[it];
        if(it==n)
        {
            lev[x]=0;
            tt[x]=0;
        }
        for(int i=0;i<v[x].size();i++)
            if(lev[x]+1>lev[v[x][i]])
              lev[v[x][i]]=lev[x]+1,tt[v[x][i]]=x;
    }
    for(i=1;i<=n;i++)
        cout<<tt[i]<<'\n';
    return 0;
}


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

using namespace std;

int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    int num = n % 10;
    if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9) cout << "hon" << '\n';
    else if (num == 0 || num == 1 || num == 6 || num == 8) cout << "pon" << '\n';
    else {
        cout << "bon" << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}



Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int ans = 0;
		for (int i = 1; i < b;) {
			ans++;
			i += (a - 1);
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

if N>=2:
    a=combinations_count(N,2)
else:
    a=0
if M>=2:
    b=combinations_count(M,2)
else:
    b=0
print(a+b)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, q;
vvi to;
vi imos;
vi ans;

void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  cin >> n >> q;
  to = vvi(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].pb(b);
    to[b].pb(a);
  }
  ans = vi(n);
  rep(qi,q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  showv(ans);
  return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	int n;
	cin >> n;
	string ans = "";
	while (n)
	{
		n--;
		char c = (n % 26) + 'a';
		ans += c;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#define int long long
using namespace std;

signed main(){
	int n,a[100000],sum = 0,cnt = 0;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		sum += a[i];
	}
	int one = n * (n + 1) / 2;
	if(sum % one){
		cout << "NO" << endl;
		return 0;
	}
	sum /= one;
	for(int i = 0;i < n;i++) {
		int d = a[(i + 1) % n] - a[i];
		if((sum - d) % n || sum < d){
			cout << "NO" << endl;
			return 0;
		}
		cnt += (sum - d) / n;
	}
	if(cnt != sum) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024