akhauriyash/Code-Regression huggingface dataset:
diagram = gets.chomp.chars

upper_skip = ->{
  loop do
    a = diagram[0]
    return false if a == "\\"
    return true unless a
    diagram.shift
  end
}

downer_skip = ->(target_height) {
  height = index = 0
  until height == target_height
    height -= 1 if diagram.shift == "\\"
    index += 1
  end
  index
}

highest = ->{
  max_index = height = 0
  max_height = -Float::INFINITY 
  diagram.size.times do |j|
    case diagram[j]
    when "\\"
      height -= 1
    when "/"
      height += 1
      max_height, max_index = height, j if max_height < height
      return [0, j] if height.zero?
    end
  end
  [max_height, max_index]
}

calc = ->(from, to) {
  depth = area = 0
  from.upto(to) do
    case diagram.shift
    when "\\"
      area += depth + 1/2r
      depth += 1
    when "_"
      area += depth
    when "/"
      depth -= 1
      area += depth + 1/2r
    end
  end
  area.to_i
}

pools = []
loop do
  break if upper_skip.()
  height, index = highest.()
  if height == -Float::INFINITY
    break
  else
    first_index = downer_skip.(height)
    pools << calc.(first_index, index)
  end
  break if diagram.size.zero?
end

if pools.empty?
  puts 0
  puts 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end


Measured memory_bytes: 8908
package main

import (
	"fmt"
	"math"
)

var N, cnt int

func main() {
	fmt.Scan(&N)
	a := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	c := make([]int, 3)

	for i := 0; i < N; i++ {
		var cnt int
		for j := 0; j < 2; j++ {
			if a[i]%2 == 0 {
				cnt++
				a[i] /= 2
			}
		}
		c[cnt]++
	}
	if c[0]+c[1] <= c[2]+1 || c[2] == c[0] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

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

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    string s, t;
    cin >> s >> t;

    if (s.length() + 1 != t.length()) {
        cout << "No" << endl;
        return 0;
    }

    rep(i, s.length()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    

    return 0;
}

Measured memory_bytes: 3652
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll arr[50];
int main() {
    cin >> N;
    int max_index = -1, max_abs = 0;
    rep(i, N){
        cin >> arr[i];
        if(max_abs < abs(arr[i])){
            max_index = i;
            max_abs = abs(arr[i]);
        }
    }
    if(max_index == -1){
        cout << 0;
        return 0;
    }

    cout << 2*N-2 << endl;
    rep(i, N){
        if(i == max_index) continue;
        cout << max_index+1 << " " << i+1 << endl;
    }
    if(arr[max_index] < 0){
        for(int i=N;i>1;i--){
            cout << i << " " << i-1 << endl;
        }
    }
    else{
        rep(i, N-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define int long long

signed  main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	map<int, int> cnt;
	for (auto ai : A) ++cnt[ai];
	ll tmp = 0;
	for (auto& e : cnt)
		tmp += e.second * (e.second - 1) / 2;
	for (int i = 0; i < N; ++i) {
		if (i != 0) {
			// i - 1の復元
			tmp -= cnt[A[i - 1]] * (cnt[A[i - 1]] - 1) / 2;
			++cnt[A[i - 1]];
			tmp += cnt[A[i - 1]] * (cnt[A[i - 1]] - 1) / 2;
		}
		// iの削除
		tmp -= cnt[A[i]] * (cnt[A[i]] - 1) / 2;
		--cnt[A[i]];
		tmp += cnt[A[i]] * (cnt[A[i]] - 1) / 2;
		// 出力
		cout << tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 12288
#include <iostream>

using namespace std;

void lucas(long long a[])
{
	for(int i = 0; i < 87; i++)
	{
		if(i == 0)
		{
			a[i] = 2;
		}
		else if(i == 1)
		{
			a[i] = 1;
		}
		else
		{
			a[i] = a[i - 1] + a[i - 2];
		}
	}
}

int main()
{
	int n;
	cin >> n;
	
	long long luc[87] = {0};
	lucas(luc);
	cout << luc[n] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,M;
  cin>>N>>M;
  vector<long long> A;
  for(long long i=1; i*i<=M; i++){
if(M%i==0) {
  A.push_back(i);
  A.push_back(M/i);
}
}
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    long long t=A.size();
    for(long long i=0; i<t; i++){
if(A[i]<=M/N){ cout<<A[i]<<endl; break;}
    }
  }

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	double ans = 0;
	cin >> n;
	while (n--)
	{
		double d;
		string s;
		cin >> d >> s;
		if (s[0] == 'J') ans += d;
		else ans += d * 380000;
	}
	printf("%.15f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    // 10x + 5y + z = Y
    // x + y + z = N
    // 9x + 4y = Y - N
    int n, yy;
    cin >> n >> yy;
    yy /= 1000;
    int x = -1, y = -1, z = -1;
    for (int i = 0; 4 * i <= yy - n; i++) {
        int t = yy - n - 4 * i;
        if (t >= 0 && t % 9 == 0 && n - t / 9 - i >= 0) {
            x = t / 9;
            y = i;
            z = n - x - y;
            break;
        }
    }
    cout << x << " " << y << " " << z << endl;
}




Measured memory_bytes: 3628
import numpy as np
from numba import njit

N = int(input())
S = input()
Q = int(input())
ks = list(map(int, input().split()))

def func(ch):
    if ch == 'D':
        return 1
    if ch == 'M':
        return 2
    if ch == 'C':
        return 3
    return 0
    
S_arr = np.array([func(ch) for ch in S], dtype = np.int32)

@njit("i8(i8, i4[:], i8)", cache = True)
def solve(N, S_arr, k):
    ans = 0
    D = 0
    M = 0
    DM = 0
    for i in range(k):
        if S_arr[i] == 1:
            D += 1
        elif S_arr[i] == 2:
            DM += D
            M += 1
        elif S_arr[i] == 3:
            ans += DM
    for i in range(k, N):
        if S_arr[i-k] == 1:
            D -= 1
            DM -= M
        elif S_arr[i-k] == 2:
            M -= 1

        if S_arr[i] == 1:
            D += 1
        elif S_arr[i] == 2:
            DM += D
            M += 1
        elif S_arr[i] == 3:
            ans += DM

    return ans

for k in ks:
    print(solve(N, S_arr, k))
    

Measured memory_bytes: 115628
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; size_t K;
    cin >> s >> K;

    size_t N = s.length();

    // {{{
    if (s == string(N, s[0])) {
        return cout << N * K / 2 << "\n", 0;
    }

    if (s.front() != s.back()) {
        size_t res = 0, cnt = 1;
        for (size_t i = 1; i < N; ++i) {
            if (s[i] == s[i - 1]) {
                cnt++;
            } else {
                res += cnt / 2;
                cnt = 1;
            }
        }
        res += cnt / 2;
        return cout << res * K << "\n", 0;
    }
    // }}}

    vector<int> used(N);
    used[0] = used[N - 1] = true;
    size_t left = 1, right = 1;
    for (size_t i = 1; i < N; ++i) {
        if (s[i] == s[i - 1]) {
            left++;
            used[i] = true;
        } else {
            break;
        }
    }

    for (size_t i = N - 1; i > 0; --i) {
        if (s[i] == s[i - 1]) {
            right++;
            used[i] = true;
        } else {
            used[i] = true;
            break;
        }
    }

    size_t base = 0;
    size_t cnt = 1;
    for (size_t i = 1; i < N - 1; ++i) {
        if (!used[i]) {
            if (s[i] == s[i - 1]) {
                cnt++;
            } else {
                base += cnt / 2;
                cnt = 1;
            }
        }
    }
    base += cnt / 2;

    cout << base * K + (left + right) / 2 * (K - 1) + left / 2 + right / 2 << "\n";

    return 0;
}


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

int main()
{
  long long a,b,k,aa,bb;
  cin >>a>>b>>k;
  if(k<=a) cout<<a-k<<" "<<b<<endl;
  else if(k<=a+b)cout<<0<<" "<<a+b-k<<endl;
  else cout<<0<<" "<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0

for i in range(min(k,a)+1):
  for j in range(min(k,a)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define zcin(type, a) type a; cin >> a;
#define zcout(a, sep1, b, sep2) cout << a << sep1 << b << sep2;
#define zfor(i, b, n) for (int i = b; i < n; ++i)
#define pb push_back
const int INF = 1e9 + 5;

using namespace std;

int main()
{
	#ifdef ME
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int n, k;
	cin >> n >> k;
	vector<int> dp(n, INF);
	vector<int> arr(n);
	for (int &x : arr)
		cin >> x;

	dp[0] = 0;
	for (int i = 0; i < n ; ++i)
	{
		for (int j = i + 1; j <= i + k; ++j)
		{
			if (j < n)
			{
				int cost = abs(arr[i] - arr[j]);
				dp[j] = min(dp[j], dp[i] + cost);
			}
		}
	}
	cout << dp[n - 1];
	
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;
const int dg5 = 1e5;
int dp[dg5 + 1];

void solve()
{
    int N;
    cin >> N;
    vector<int> h(N);
    REP0(i, N)
    {
        cin >> h[i];
        if (i == 0)
            continue;
        else if (i == 1)
            dp[1] = abs(h[0] - h[1]);
        else
            dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

class requirement {
public:
  i64 a;
  i64 b;
  i64 c;
  i64 d;

  friend std::istream& operator>>(std::istream& is, requirement& self) {
    std::istream& result = is >> self.a >> self.b >> self.c >> self.d;
    --self.a;
    --self.b;
    return result;
  }
};

int main() {
  i64 N, M, Q;
  std::cin >> N >> M >> Q;
  std::vector<requirement> requirements;
  tools::read(requirements, Q);

  i64 answer = std::numeric_limits<i64>::min();
  std::vector<i64> A;
  std::function<void(void)> dfs;
  dfs = [&]() {
    if (static_cast<i64>(A.size()) == N) {
      i64 possible_answer = 0;
      for (const requirement& requirement : requirements) {
        if (A[requirement.b] - A[requirement.a] == requirement.c) {
          possible_answer += requirement.d;
        }
      }
      answer = std::max(answer, possible_answer);
    } else {
      for (i64 i = A.empty() ? 1 : A.back(); i <= M; ++i) {
        A.push_back(i);
        dfs();
        A.pop_back();
      }
    }
  };
  dfs();

  std::cout << answer << std::endl;
  return 0;
}

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

int a[]={10,2,2,4,7,18,3,7,5,25,3,19,13,30,13,2,1,1,2,3,44,22,14,4,13,3,1,3,2,15,23,2,2,5,3,4,3,15,2,1,5,6,1,1,12,6,17,1,4,5,3,6,2,3,13,4,1,19,3,1,5,15,10,1,16,23,2,14,1,18,9,21,1,15,2,13,1,1,18,3,3,17,3,18,4,8,1,24,7,3,2,22,10,5,4,6,5,18,1,1,3,3,16,1,2,3,15,2,5,3,13,14,4,6,5,5,4,41,3,11,15,2,2,2,1,9,3,17,2,2,0,8,1,7,10,3,3,1,3,2,6,4,32,12,10,11,4,15,8,23,11,1,2,1,23,2,17,1,2,7,2,1,11,6,1,7,18,4,18,4,5,7,1,3,20,24,13,5,2,31,4,3,22,1,8,1,1,1,3,16,4,2,3,6,1,9,9,13,3,7,13,1,0,1,4,16,13,26,1,2,15,1,4,1,24,3,1,3,5,0,2,10,13,2,3,1,8,1,6,9,2,1,23,18,4,3,3,14,3,4,1,1,1,3,3,8,7,2,1,6,18,1,21,2,5,1,8,2,21,13,1,2,11,6,7,24,1,1,18,1,2,2,1,6,1,9,3,7,13,34,6,2,3,18,6,19,3,13,4,12,3,3,17,3,1,4,18,5,6,1,5,10,22,7,11,2,1,1,3,25,6,1,2,2,0,23,10,9,2,1,3,2,29,4,4,1,10,2,4,2,1,19,18,31,0,17,29,3,31,6,1,23,1,21,17,1,1,20,1,6,3,4,13,6,13,5,5,16,5,9,13,3,1,17,1,1,15,9,3,1,6,4,7,4,1,6,1,2,2,18,22,1,9,1,1,1,6,4,26,4,1,23,20,7,6,1,39,1,12,3,1,3,5,3,4,2,16,2,2,1,4,3,19,1,6,6,2,9,3,12,1,10,1,17,8,1,9,2,45,6,2,17,31,1,3,11,2,24,1,0,0,3,8,5,2,2,2,2,8,4,19,3,3,37,6,7,2,21,3,3,3,9,3,13,10,2,7,7,1,1,19,12,13,3,1,40,1,9,10,0,1,15,1,42,3,5,3,8,1,4,2,3,3,3,3,18,19,3,7,1,1,19,20,4,1,27,1,12,1,1,5,2,4,2,1,32,1,13,5,4,3,0,4,9,4,3,23,1,13,2,3,23,1,18,11,4,6,13,3,13,6,2,2,4,5,41,32,3,6,4,6,9,6,3,1,1,1,4,24,3,1,3,10,32,1,3,7,13,19,1,31,2,36,2,3,6,6,20,1,1,0,25,13,24,12,10,14,5,0,1,8,10,25,12,32,1,41,5,8,24,8,1,16,1,20,45,1,6,3,1,24,27,1,16,2,1,7,38,2,5,19,15,9,3,1,3,4,27,3,2,3,0,1,6,13,7,10,18,2,2,1,1,2,30,3,8,27,3,16,4,2,14,13,26,18,13,2,3,0,11,1,9,3,14,9,12,1,1,22,6,12,10,9,7,9,0,1,1,4,7,2,1,5,19,1,12,19,4,6,3,2,10,4,7,8,2,8,1,17,0,10,4,4,7,1,3,3,16,13,2,1,3,10,15,5,1,17,5,11,7,3,3,2,2,10,22,3,1,5,2,9,4,3,2,1,10,3,24,3,7,3,2,6,13,3,2,22,1,32,2,4,6,2,16,4,13,10,3,21,1,2,11,3,3,20,3,3,1,5,15,1,18,21,1,0,24,13,5,14,1,13,1,6,2,2,11,5,1,4,3,9,5,5,1,19,17,5,5,8,15};

int main(void){
	for(int i=0;i<800;i++){
	cout << a[i] << endl;
	}
	return 0;
}

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

using type = pair<int, long long>; // 1: query, 0; delete, -1: insert
using event = pair<long long, type>;

int main() {
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
}


Measured memory_bytes: 27748
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def divisors(n):
    # 約数列挙

    divisors = []

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

    return divisors


def main():
    n = int(readline())
    divs = divisors(n)
    ans = INF

    for a in divs:
        b = n // a
        score = max(len(str(a)), len(str(b)))
        ans = min(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;

    vector<vector<ll>> dp(N + 1, vector<ll>(100005, INF));
    dp[0][0] = 0;
    rep(i, N) {
        P p = items[i];
        rrep(j, 100000, 0) {
            if (j - p.second >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - p.second] + p.first);
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i, 100004) {
        if (dp[N][i] <= W) {
            ans = max(ans, i);
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 80256
n = int(input())
a = list(map(int, input().split()))
max = 60
ans = 0
mod = 10**9 + 7
for i in range(max):
    one = 0
    for ai in a:
        if (ai >> i) & 1:
            one += 1
    ans += one*(n - one)*2**i
ans %= mod
print(ans)
    

Measured memory_bytes: 122808
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    assert(h<=300 && w<=300);
    vector<vector<int>> v(h,vector<int>(w));
    rep(i,h)rep(j,w)cin>>v[i][j];
    rep(i,h)rep(j,w)v[i][j]--;
    
    priority_queue<pii,vector<pii>,greater<pii>> pq[400];
    rep(i,h){
        rep(j,w){
            pq[i].push(pii(j,v[i][j]));
        }
    }
    
    int less = w;
    vector<bool> used(400,false);
    
    int ans = h;
    while(less){
        vector<int> score(400,0);
        rep(i,h){
            while( pq[i].size() && used[ pq[i].top().second ]==true )pq[i].pop();
            assert( used[ pq[i].top().second ] == false );
            score[pq[i].top().second]++;
        }
        int res = *max_element(all(score));
        ans = min(ans, res);
        rep(j,w){
            if(score[j]==res){
                assert(used[j]==false);
                used[j] = true;
                less--;
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1792
S = [int(x) if x != '?' else - 1 for x in input()]

dp=[(i,0) for i in range(13)]
dp=dict(dp)
dp[0]=1

i=0
mul=1

for k in reversed(S):
    newdp=dict([(i,0) for i in range(13)])
    if k==-1:
        for s in range(10):
            for j in range(13):               
                newdp[(mul*s + j) % 13] += dp[j]%(10**9+7)
    else:
        for j in range(13):
            newdp[(mul*k + j) % 13] += dp[j]%(10**9+7)
    dp=newdp
    mul = (mul *10)%13


print(dp[5]%(10**9+7))


Measured memory_bytes: 46700
n,l = map(int,input().split())
a = 0
for i in range(n):
    a += l + i

mi = 1000000000000000000000
for i in range(n):
    b = a - l - i
    c = abs(a-b)
    if c < mi:
        mi = c
        minsum = b

print(minsum)

Measured memory_bytes: 3060
class UnionFind:

    def __init__(self, n: int):
        self._n = n
        self._parents = [i for i in range(n)]
        self._rank = [1 for _ in range(n)]

    def unite(self, x: int, y: int) -> None:
        px = self.find(x)
        py = self.find(y)

        # 一致していないときはリンクをつける
        if px != py:
            self._link(px, py)

    def _link(self, x: int, y: int):
        if self._rank[x] < self._rank[y]:
            self._parents[x] = y
        elif self._rank[x] > self._rank[y]:
            self._parents[y] = x
        else:
            self._parents[x] = y
            self._rank[y] += 1

    def same(self, x: int, y: int) -> bool:
        px = self.find(x)
        py = self.find(y)
        return px == py

    def find(self, x: int) -> int:
        if self._parents[x] == x:
            return x

        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]



n, m = map(int, input().split())

uf = UnionFind(n)

for _ in range(m):
    x, y, _ = map(int, input().split())
    uf.unite(x - 1, y - 1)

s = set()
for i in range(0, n):
    s.add(uf.find(i))

print(len(s))


Measured memory_bytes: 16784
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int k;
	cin >> k;
    int ans = (k/2) * ((k+1)/2);
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll f(ll x,ll b){
	ll res = 0;
	while(x){
		res += x%b;
		x/=b;
	}
	return res;
}
ll n,s;
int main(){
	cin >> n >> s;
	if(n<s){
		cout << -1 << endl;
		return 0;
	}else if(n==s){
		cout << n+1 << endl;
		return 0;
	}
	for(ll i=2;i<400000;i++){
		if(s==f(n,i)){
			cout << i << endl;
			return 0;
		}
	}
	ll K = n-s;
	ll ans = -1;
	for(ll i=1;i*i<=K;i++){
		if(K%i!=0)continue;
		ll p = i;
		ll b = K/i+1ll;
		if(p<b&&s-p>=0&&s-p<b){
			ans = b;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python                                                                                          
#-*- coding: utf-8 -*-                                                                                         

if __name__ == "__main__":
    N = int(raw_input())
    A = []
    B = []
    for n in range(N):
        input = map(int, raw_input().split())
        A.append(input[0])
        B.append(input[1])
    minimam = min(B)
    print A[B.index(minimam)] + minimam

Measured memory_bytes: 12084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	xm := make(map[int]int, n)
	for i := 1; i <= n; i++ {
		a := readInt()
		xm[i] = a
	}

	b := 1
	ans := 0
	for {
		if _, ok := xm[b]; !ok {
			fmt.Println(-1)
			return
		}
		old := b
		b = xm[b]
		delete(xm, old)
		ans++
		if b == 2 {
			fmt.Println(ans)
			return
		}
	}
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
int a[200200],n;
inline bool check(int k){
	std::map<int,int> map;
	for(int i = 1;i <= n;++i) if(a[i] <= a[i - 1]){
		while(map.size() && map.rbegin() -> first > a[i - 1]) map.erase(--map.end());
		int now = a[i];
		for(;now > 0 && ++map[now] == k;--now) map[now] = 0;
		if(now <= 0) return 0;
	}
	return 1;
}
int main(){
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> n; int flg = 1;
	for(int i = 1;i <= n;++i) std::cin >> a[i],flg &= a[i] > a[i - 1];
	if(flg) return std::cout << 1 << '\n',0;
	int l = 1, r = n;
	for(;l + 1 != r;){
		int mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid;
	}
	std::cout << r << '\n';
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  vector<long long> S(N+1);
  S.at(0) = 0;
  for (int i = 0; i < N; i++) {
    S.at(i+1) = S.at(i) + A.at(i);
  }
  sort(S.begin(), S.end());

  long long ans = 0, count = 1;
  for (int i = 1; i < N+1; i++) {
    if (S.at(i) == S.at(i-1)) {
      count++;
    } else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 2560
n=int(input())
D=[]
for i in range(n):
    s,t=input().split()
    D.append((s,t))
x=input()

ans=0
flag=False
for i in  range(n):
    if flag:
        ans+=int(D[i][1])
    if x==D[i][0]:
        flag=True

print(ans)
        


Measured memory_bytes: 3068
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
class Edge {
public:
    ll t;
    ll w;
    Edge() {}
    Edge(ll t, ll w): t(t), w(w) {}
};


int main(void) {
    ll N;
    ll a[100000];
    ll sub[100000];
    ll i;
    ll sum=0;
    ll count;
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> a[i];
        sum+=a[i];
    }
    
    for(i=0; i<N; i++) {
        sub[i]=a[(i+1)%N]-a[i];
    }
    
    if(sum*2%(N*(N+1))!=0) {
        pNO;
        return 0;
    }
    
    count=sum*2/N/(N+1);
    
    ll ans=0;
    for(i=0; i<N; i++) {
        sub[i]-=count;
        if(sub[i]>0) {
            pNO;
            return 0;
        }
        
        if(sub[i]<0 && abs(sub[i])%N==0) {
            ans+=abs(sub[i])/N;
        }
    }
    
    if(ans==count) pYE;
    else pNO;
}


Measured memory_bytes: 1792
//
// Created by kuroneko on 2019-09-01.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    string s, t; cin >> s >> t;
    int res = 0;
    if (s[0] == t[0]) res++;
    if (s[1] == t[1]) res++;
    if (s[2] == t[2]) res++;
    cout << res << endl;
}


Measured memory_bytes: 888
S = input()
lst = ['A', 'G', 'C' ,'T']
max_num = 0
for i in range(len(S)):
    cnt = 0
    if S[i] in lst:
        cnt += 1
        for j in range(i+1, len(S)):
            if S[j] in lst:
                cnt += 1
            else:
                break
    if cnt > max_num:
        max_num = cnt

print(max_num)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int a[100111];
int b[100111];

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    int min_a = 100111;
    int min_b = 100111;
    for (int i = 0; i < A; i++) {
        cin >> a[i];
        min_a = min(a[i], min_a);
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
        min_b = min(b[i], min_b);
    }
    int ans = min_a + min_b; // 一番安いものを別個で買う
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	vector<string> v;
	map<string, ll> cnt;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		vector<int> t(26, 0);
		for(int j=0; j<10; j++) t[s[j]-'a']++;
		string ss="";
		for(int j=0; j<26; j++){
			for(int k=0; k<t[j]; k++){
				ss+=(char)('a'+j);
			}
		}
		if(cnt[ss]==0) v.push_back(ss);
		cnt[ss]++;
	}

	ll ans=0;
	for(int i=0; i<v.size(); i++){
		ans+=cnt[v[i]]*(cnt[v[i]]-1)/2;
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
  
  int N;
  cin >> N;
  int ans;
  
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    ans += b-a+1;
  }
 
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int, read().split())
dp = [0, 0, 0]
for a, b, c in zip(m, m, m):
    dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c]

print(max(dp))

Measured memory_bytes: 28132
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
 	cin>>s;
 	for(int i=0;i<s.size();i++)
	if(s[i]=='C')
	for(int j=i+1;j<s.size();j++)
	if(s[j]=='F'){cout<<"Yes";return 0;}
	cout<<"No";	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long ZTF = sc.nextLong();
		long F025 = ZTF * 4;

		long ZFZ = sc.nextLong();
		long F050 = ZFZ * 2;

		long One = sc.nextLong();
		long F100 = One;

		long Two = sc.nextLong();

		long want = sc.nextLong();

		long ans;

		Long[] nums = {F025,F050,F100};//ここで0.25、0.50、1.00のどれを使うか決める
		int min = 0;
		for(int i = 0;i < 3; i++) {
			if(nums[min] > nums[i]) {
				min = i;
			}
		}

		if(nums[min] * 2 > Two && want >= 2) {
			if(want % 2 == 0) {
				ans = Two * (want / 2);
			} else {
				ans = Two * (want / 2) + nums[min];
			}
		} else  {
			ans = nums[min] * want;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
int main(){
	char A[1200] = {0};
	char B[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	char C[] = {"abcdefghijklmnopqrstuvwxyz"};
	int D[26] = {0};
	char ch;	
	//gets(A);
	
	for(int i = 0; scanf("%c", &ch) != EOF; i++){
    	A[i] = ch;
	}
	
	
	for(int i = 0; i < 1200; i++){
		for(int j = 0; j < 26; j++){
			if(A[i] == B[j]){
				A[i] = C[j];
				break;
			}
		}
	}
	
	for(int i = 0; i < 1200; i++){
		for(int j = 0; j < 26; j++){
			if(A[i] == C[j]){
				D[j]++;
				break;
			}
		}
	}
	
	for(int i = 0; i < 26; i++){
		printf("%c : %d\n", C[i], D[i]);
	}
  	return 0;
}

Measured memory_bytes: 968
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
	int n; cin >> n;
	std::vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	if(a[n-1]==0){
		cout << "Yes" << endl;
		return 0;
	}
	if(n%3==0){
		for(int i=0;i<n/3;i++){
			if(a[i]!=a[0]){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=n/3;i<n/3+n/3;i++){
			if(a[i]!=a[n/3]){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=n/3+n/3;i<n;i++){
			if(a[n/3+n/3]!=a[i]){
				cout << "No" << endl;
				return 0;
			}
		}
		int m=a[0];int l=a[n/3];int j=a[n/3+n/3];
		//cout << m << l << j << endl;
		if((m^l)==j&&(m^j)==l&&(j^l)==m){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    int x,limit;
    cin >> x;
    limit = pow(x,1.0/5.0);
    for(int i=0;i<=limit;i++){
        for(int j=0;j>=-limit;j--){
            if(x==pow(i,5)-pow(j,5)){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    for(long long i=limit;;i++){
        for(long long j=0;j<i;j++){
            if(x==pow(i,5)-pow(j,5)){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4064
#include<stdio.h>
int main(void)
{
	int n,m,a[1001],b[1001],i,j,x[1001],y,z;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=0;i<m;i++)	scanf("%d",&b[i]);
	for(i=0;i<n;i++)	x[i]=0;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(a[j]<=b[i]){
				x[j]++;
				break;
			}			
		}
	}
	y=0;
	for(i=0;i<n;i++){
		if(x[i]>y){
			y=x[i];
			z=i;
		}
	}
	z=z+1;
	printf("%d\n",z);
	return 0;
}


		
	


Measured memory_bytes: 2136
import math
import itertools

n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
l = [i for i in range(n)]
a = float(0)

k = list(itertools.permutations(l,n))
for i in range(math.factorial(n)):   
    for j in range(n-1):
        a += (((x[k[i][j]]-x[k[i][j+1]]) ** 2) + ((y[k[i][j]]-y[k[i][j+1]]) ** 2)) ** 0.5
        
print(a/math.factorial(n))


Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
string s;
void dfs(int x) {
	if(x==0) {
		return ;
	}
	if(x%2==0) {
		s+="0";
		dfs(x/(-2));
		return ;
	}
	s+="1";
	dfs((x-1)/(-2));
	return ;
}
int main() {
	int n;
	cin>>n;
	if(n==0) {
		cout<<n;
		return 0;
	}
	dfs(n);
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

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

S = input()
l = len(S) - 1
cnt1, cnt2 = 0, 0
for i in range(l):
    if i % 2:
        if S[i] != '0':
            cnt1 += 1
    else:
        if S[i] != '1':
            cnt1 += 1
for i in range(l):
    if i % 2:
        if S[i] != '1':
            cnt2 += 1
    else:
        if S[i] != '0':
            cnt2 += 1
print(min(cnt1, cnt2))

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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    ll v;
    vector<ll> f;
    cin >> n;
    while(n--) {
        cin >> v;
        f.push_back(v);
    }
    sort(f.begin(), f.end(), greater<ll>());
    deque<ll> q;
    ll res = 0;
    q.push_back(f[0]);
    for(int i=1;i<f.size();i++) {
        res += q.front(); q.pop_front();
        q.push_back(f[i]); q.push_back(f[i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() - 1;
		int b = sc.nextInt() - 1;
		char[][] c = new char[100][100];
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 100; j++) {
				c[i][j] = '#';
			}
		}
		for (int i = 50; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				c[i][j] = '.';
			}
		}

		int h = 0;
		int w = 0;
		while (a > 0) {
			c[h][w] = '.';
			a--;
			w += 2;
			if (w >= 100) {
				h += 2;
				w = 0;
			}
			if (h >= 50) break;
		}

		h = 99;
		w = 0;
		while (b > 0) {
			c[h][w] = '#';
			b--;
			w += 2;
			if (w >= 100) {
				h -= 2;
				w = 0;
			}
			if (h < 50) break;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				sb.append(c[i][j]);
			}
			sb.append("\n");
		}
		System.out.println("100 100");
		System.out.print(sb.toString());
	}
}


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

int main() {

    int n,k;

    cin >> n >> k;

    int ans = 0;

    for(int i=0; i<n; i++){

        int x;
        cin >> x;

        if(k-x > x){
            ans += x*2;
        }
        else{
            ans += (k-x)*2;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");            
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vp vector<pair<int,int>>
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(),x.end()
#define cmp(t,x) [](const t& _a,const t& _b) {return _a.x<_b.x;}
#define pq priority_queue
const long long p = (long long)1e9+7;
ll fmp(ll a,ll n,ll p){
	if (a==0) return 0;
	if (n==0) return 1;
	if (a==1) return a%p;
	ll ans = (fmp(a,n/2,p));ans=(ans*ans)%p;
	if (n%2) ans=(ans*a)%p;
	return ans;
}

int main(){
    ios::sync_with_stdio(true);
    cin.tie(NULL);
    ll n;cin>>n;
    cout<<((fmp(10,n,p)-2*fmp(9,n,p)+fmp(8,n,p))%p+p)%p;
    
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int r=0;
    while(true){
        for(int i=0;i<n;i++){
            if(a[i] % 2 != 0){
                cout << r << endl;
                return 0;
            }else{
                a[i] = a[i] / 2;
            }
        }
        r++;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            int x = Integer.parseInt(br.readLine());
            System.out.println(x*x*x);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

#define mp make_pair
#define fst first
#define snd second
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend();
#define forn(i,n) for (long long i = 0; i < (long long)(n); i++)
#define fornr(i,n) for (long long i = (long long)(n)-1; i >= 0; i--)

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;

template <typename T>
T id(T b) {return b;};
template <class It>
bool for_all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool exists(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 500;
int n,m,q;
vi seg[MAX_N];

int main()
{
  cin >> n >> m >> q;
  int a,b;
  while (m--) {
    cin >> a >> b;
    a--,b--;
    seg[b].push_back(a);
  }

  forn (i,n) {
    sort(all(seg[i]));
  }

  int l,r;
  while (q--) {
    cin >> l >> r;
    l--,r--;
    int res = 0;
    for (int i = l; i <= r; i++) {
      res += seg[i].end() - lower_bound(all(seg[i]),l);
    }
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
// King's Inspection
import java.util.Scanner;

public class Main {
	static char[] sta = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
			'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
			'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
			'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
			'X', 'Y', 'Z' };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int[] keys = new int[n];
			for (int i = 0; i < n; i++)
				keys[i] = sc.nextInt();
			String stations = sc.next();
			StringBuilder result = new StringBuilder();
			for (int i = 0; i < stations.length(); i++) {
				char c = stations.charAt(i);
				int d;
				if (Character.isLowerCase(c))
					d = c - 'a';
				else
					d = c - 'A' + 26;
				d += 52 - keys[i % n];
				d %= 52;
				result.append(sta[d]);
			}
			System.out.println(result);
		}
		sc.close();
	}
}

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

int main()
{
  int64_t N, c = 1000;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  int64_t prev = A.at(0), idx = 0;
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) <= A.at(idx))
    {
      idx = i;
      continue;
    }
    if (i != N - 1 && A.at(i + 1) > A.at(i))
      continue;
    int64_t st = c / A.at(idx), r = c % A.at(idx);
    c = A.at(i) * st + r;
    idx = i + 1;
  }
  cout << c << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    string S, T; cin >> S >> T;
    map<char, char> st;
    map<char, char> ts;

    REP(i, S.size()) {
        char x = S[i];
        char y = T[i];
        if (st.count(x) == 0) {
            st[x] = y;
        } else {
            if (st[x] != y) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (ts.count(y) == 0) {
            ts[y] = x;
        } else {
            if (ts[y] != x) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ext/pb_ds/priority_queue.hpp>
#define MAX_N 200005

using namespace std;

typedef pair<int,int> P;

int n,m;
int dis[MAX_N];
bool vis[MAX_N];
vector<int> edge[MAX_N];
__gnu_pbds::priority_queue<P,greater<P> > q;

void dij(int s)
{
	memset(dis+1,0x3f,sizeof(int)*n);
	dis[s]=0,q.push(P(0,s));
	while(!q.empty())
	{
		int x=q.top().second; q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		for(int i=0;i<edge[x].size();i++)
		{
			int t=edge[x][i];
			if(dis[t]>dis[x]+1)
			{
				dis[t]=dis[x]+1;
				q.push(P(dis[t],t));
			}
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	dij(1);
	printf("%s\n",dis[n]<=2 ? "POSSIBLE" : "IMPOSSIBLE");
}


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

int main(){

    string s;
    cin>>s;
    int s1=(s[0]-'0')*10+s[1]-'0';
    int s2=(s[2]-'0')*10+s[3]-'0';

    if(s1>=1&&s1<=12&&s2>=1&&s2<=12) cout<<"AMBIGUOUS"<<endl;
    else if(s1>=1&&s1<=12) cout<<"MMYY"<<endl;
    else if(s2>=1&&s2<=12) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
int n,a[N];
bool check (int x)
{
	for (int i=0; i< n-1; i++)
	{
		if (a[n+i]> x&&a[n+i+1]> x) return 0;
		if (a[n-i]> x&&a[n-i-1]> x) return 0;
		if (a[n+i]<=x&&a[n+i+1]<=x) return 1;
		if (a[n-i]<=x&&a[n-i-1]<=x) return 1;
	}
	return a[1]<=x;
}
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i< n*2; i++)
		sc(a[i]);
	int L=0,R=2*n;
	while (L+1< R)
	{
		int mid=(L+R)>>1;
		if (check (mid)) R=mid;
		else L=mid;
	}
	pr(R);

	return 0;
}


Measured memory_bytes: 896