akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2 = scan.next();
		char[] arr1 = str1.toCharArray();
		char[] arr2 = str2.toCharArray();
		int len1 = arr1.length;
		int len2 = arr2.length;
		int[][] dp = new int[len1 + 1][len2 + 1];
		for(int i = 1 ; i <= len1; i++) {
			for(int j = 1 ; j <= len2 ; j++) {
				if(arr1[i - 1] == arr2[j - 1])
					dp[i][j] = dp[i-1][j-1] + 1;
				else dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
			}
		}
		StringBuilder sb = new StringBuilder();
		int i = len1 , j = len2;
		while(i > 0 && j > 0) {
			if(arr1[i-1] ==arr2[j - 1]) {
				sb.append(arr1[i - 1]);
				i--;
				j--;
			}
			else {
				if(dp[i-1][j] > dp[i][j-1]) {
					i--;
				}
				else {
					j--;
				}
			}
		}
		System.out.println(sb.reverse());
	}
}


Measured memory_bytes: 83020
// 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_LEN 1000
// 無効な値の定義
const int INV = -1;

int longestCommonSubstring(char a[], char b[]);

int main(void)
{

    int q, len;
    char first_str[MAX_LEN], second_str[MAX_LEN];

    cin >> q;

    for(int i = 0; i < q; i++)
    {
        cin >> first_str;
        cin >> second_str;

        len = longestCommonSubstring(&first_str[0], &second_str[0]);
        printf("%d\n", len);
    }



    return 0;
}

// 最長共通部分列を算出する関数
int longestCommonSubstring(char a[], char b[])

{
    int dp[MAX_LEN + 1][MAX_LEN + 1];
    int a_len, b_len;

    a_len = strlen(a);
    b_len = strlen(b);

    // 配列の初期化
    for(int i = 0; i < a_len; i++)
    {
        for(int j = 0; j < b_len; j++)
        {
            dp[i][j] = INV;
        }
    }

    for(int i = 0; i < a_len; i++)
    {
        dp[i][0] = 0;
    }

    for(int j = 0; j < b_len; j++)
    {
        dp[0][j] = 0;
    }

    // 最長共通部分列の算出
    for(int i = 1; i <= a_len; i++)
    {
        for(int j = 1; j <= b_len; j++)
        {
            if( a[i - 1] == b[j - 1] )
            {
                // 最後の文字が一致している時
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                // 最後の文字が一致していない時
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

	return dp[a_len][b_len];
}



Measured memory_bytes: 7100
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(ll)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = _begin + (_end - _begin) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vector<ll> v;
map<ll, int> mp;
ll ans = {};

bool check(ll x){

}
void solve(){
  // main algorithm
  ans = 0LL;
  for (int i = 0; i < N; ++i)
  {
    mp[A[i]]++;
  }
  for(auto&& p : mp) {
    auto val = p.first;
    auto cnt = p.second;
    if (cnt < val)
    {
      ans += cnt;
    }else if(cnt > val){
      ans += cnt - val;
    }
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
LL f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n);
    f[0]=1;
    FOR(i,1,60){
       f[i]=f[i-1]*2;
    }
    FOR(i,0,60){
        if(n<f[i]){
            cout<<f[i]-1<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string s;
    cin >> s;
    int N = s.size();
    int a;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    int b;
    for (int i = N - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            b = i;
            break;
        }
    }
    int ans = b - a + 1;
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    x = f ? -x : x;
}
template <class T>
inline void write(T x) {
    if (x < 0) { putchar('-'); x = -x; }
    T y = 10, len = 1;
    while (y <= x) { y *= 10; ++len; }
    while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}

const int MAXN = 2010;

bitset <MAXN * MAXN> f;

int n, x, sum;

int main() {
	read(n);
	f[0] = 1;
	for (int i = 1; i <= n; ++i) { read(x); f |= f << x; sum += x; }
	for (int i = (sum + 1) >> 1; i <= sum; ++i) if (f[i]) { printf("%d\n", i); return 0; }
	return 0;
}

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

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

    int n;
    cin >> n;

    auto *p = (uint64_t *)calloc(1000000000 / 8, 1);
    int r = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;

        auto m = 1ULL << a % 64;
        r += ((p[a / 64] ^= m) & m) != 0;
    }

    cout << r * 2 - n << endl;

    quick_exit(0);
}

Measured memory_bytes: 122240
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int n,m;
  int a,b;
  int count=0;
  
  cin>>n>>m;
  
  vector<long long int> h(n);
  vector<int> check(n);
  fill(check.begin(),check.end(),0);
  
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  
  for(int j=0;j<m;j++)
  {
    cin>>a>>b;
    
    if(h[a-1]<h[b-1])
    {
      check[a-1]=-1;
      if(check[b-1]==0)
      {
        check[b-1]=1;
      }
    }
    else if(h[a-1]==h[b-1])
    {
      check[a-1]=-1;
      check[b-1]=-1;
    }
    if(h[a-1]>h[b-1])
    {
      check[b-1]=-1;
      if(check[a-1]==0)
      {
        check[a-1]=1;
      }
    }
  }
  
  for(int s=0;s<n;s++)
  {
    if(check[s]==-1)
    {
      count++;
    }
  }
  
  cout<<n-count<<endl;
  
  return 0;
}


Measured memory_bytes: 4568
def make_new_vocab(voc):
    max_let = ord(max(voc)) - 97
    let = [chr(ord('a') + i) for i in range(26)]

    for i in range(max_let + 2):
        yield voc + let[i]


n = int(input())
vocabs = ["a"]


for i in range(1, n):
    new_vocabs = []
    for voc in vocabs:
        for p in make_new_vocab(voc):
            new_vocabs.append(p)
    vocabs = new_vocabs

for ans in vocabs:
    print(ans)

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

int main(){
  int N, P; cin >> N >> P;
  int odd=0;
  for(int i=0;i<N;i++){
    int k; cin >> k;
    if(k%2==1){
      odd++;
    }
  }
  long long ans=1;
  for(int i=0;i<N;i++){
    ans*=2;
  }
  if(odd>0){
    ans/=2;
  }
  if(odd==0 && P==1){
    ans=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n;
ll a[200005],b[200005];
ll A[200005];
ll ANS;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		A[i]=b[i]*(b[i]-1)/2;
		ANS+=A[i];
	}
	for(int i=0;i<n;i++){
		cout<<ANS-A[a[i]]+(b[a[i]]-1)*(b[a[i]]-2)/2<<endl;
	}
	
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        for(int j = i; j>0 && a[j-1]>a[j]; j--) swap(a[j], a[j-1]);
        rep(i,n){
            if(i==n-1) cout << a[n-1] << endl;
            else cout << a[i] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3112
T = input()
P = input()


class RollingHash:
    def __init__(self, s):
        self.s = s
        self.n = len(s)
        self.hash1 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        self.base1, self.mod1 = pow(2, 64) - 1, 10 ** 9 + 7

        self.construct()

    def construct(self):
        for i, c in enumerate(self.s):
            self.hash1[i + 1] = ((self.hash1[i] * self.base1) % self.mod1 + ord(c)) % self.mod1
            self.power1[i + 1] = (self.power1[i] * self.base1) % self.mod1

    # [l, r)
    def get_hash(self, l, r):
        res1 = (self.hash1[r] - (self.hash1[l] * self.power1[r - l] % self.mod1)) % self.mod1
        return [res1]


rh_t = RollingHash(T)
rh_p = RollingHash(P)
p_hash = rh_p.get_hash(0, len(P))
for i in range(len(T) - len(P) + 1):
    if rh_t.get_hash(i, i + len(P)) == p_hash:
        print(i)



Measured memory_bytes: 86644
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int r;
  std::cin >> r;
  std::cout << 3* r* r << '\n';
  return 0;
}


Measured memory_bytes: 888
make=False
def check_possible(req,num):
  for i in range(0,req+1):
      for j in range(0,req+1):
          if 2*i+4*j==num and i+j==req:
              return True
  return False
req,num=list(map(int,input().split()))
if check_possible(req,num):
  print("Yes")
else:
  print("No")
  
  

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

using namespace std;

int main (void) {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for ( int i = 0; i < H; i++ ) {
        cin >> S.at(i);
    }

    /* ある場所においたとき、縦・横方向に
     * いくつ照らせるかのマップを別個に作る */
    vector<vector<int>> ver(H, vector<int>(W));
    vector<vector<int>> hor(H, vector<int>(W));

    for ( int y = 0; y < H; y++ ) {
        for ( int sx = 0; sx < W; sx++ ) {
            int sum = 0;
            int x = sx;
            while ( x < W && S.at(y).at(x) != '#' ) {
                sum++;
                x++;
            }
            assert(x <= W);
            for ( int i = x - 1; i >= sx; i-- ) {
                hor.at(y).at(i) = sum;
            }
            sx = x;
        }
    }

    for ( int x = 0; x < W; x++ ) {
        for ( int sy = 0; sy < H; sy++ ) {
            int sum = 0;
            int y = sy;
            while ( y < H && S.at(y).at(x) != '#' ) {
                sum++;
                y++;
            }
            assert(y <= H);
            for ( int i = y - 1; i >= sy; i-- ) {
                ver.at(i).at(x) = sum;
            }
            sy = y;
        }
    }

    int ans = 0;
    for ( int y = 0; y < H; y++ ) {
        for ( int x = 0; x < W; x++ ) {
            int cand = hor.at(y).at(x) + ver.at(y).at(x) - 1;
            if ( cand > ans )
                ans = cand;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35712
#include <stdio.h>

int main()
{
	int x, y;

	scanf("%d", &x);

	if (x < 1 || 100 < x) {
		fprintf(stderr, "invalid input %d\n", x);
		return 1;
	}

	y = x * x * x;

	printf("%d\n", y);

	return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
int main(void){

   int n;
   int a,b;
   scanf("%d",&n);
   if(n==1){
      printf("Hello World");
}
   else if(n==2){
      scanf("%d",&a);
      scanf("%d",&b);
      printf("%d",a+b);
}
return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	map<string, int> m;
	int n;
	cin >> n;
	for(; n; --n)
	{
		string s;
		cin >> s;
		m[s] = 1;
	}
	cout << m.size() << '\n';
    return 0;
}


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

int main() {
  int n, m, total;
  cin >> n >> m;
  int a[n][m];
  int c[m];
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++) {
    cin >> c[j];
  }
  
  for (int i = 0; i < n; i++) {
    total = 0;
    for (int j = 0; j < m; j++) {
      total += a[i][j] * c[j];
    }
    cout << total << endl;
  }
}



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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

int get_digit(int num) {
    if (num == 0) {
        return 1;
    }
    return static_cast<int>(log10(num)) + 1;
}

void solve(long long N, long long P, string S) {
    ll ans = 0;
    if ((10 % P) == 0) {
        for (auto i = N - 1; i >= 0; i--) {
            if (((S[i] - '0') % P) == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return;
    } else {
        vl t(N + 1);
        ll exp = 1;
        for (auto i = N - 1; i >= 0; i--) {
            t[i] = (t[i + 1] + (S[i] - '0') * exp) % P;
            exp *= 10;
            exp %= P;
        }

        vi count(P);
        for (auto item : t) {
            count[item]++;
        }
        // count[0]++; t[N]がこの役目を果たすので消して良い
        for (ll item : count) {
            ans += item * (item - 1) / 2;
        }

        cout << ans << endl;
        return;
    }
}

int main() {
    long long N;
    std::cin >> N;
    long long P;
    std::cin >> P;
    string S;
    std::cin >> S;
    solve(N, P, S);
    return 0;
}


Measured memory_bytes: 2308
#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"

using namespace std;

//ll const N = 32000;

ll arr[1000000], prod[1000000];

int main()
{
    ll N, K, a = 0;
    scanf("%lld %lld", &N, &K);

    for(int i = 1; i <= N; i++)
    {
        scanf("%lld", &arr[i]);

        arr[i] += arr[i - 1];
    }

    for(int i = K + 1; i <= N; i++)
    {
        if(arr[i] - arr[i - K] > arr[i - 1] - arr[i - 1 - K])printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 5324
"use strict";

const main = arg => {

    const input = arg.trim().split("\n");

    const N = parseInt(input[0]);
    let as = input[1].trim().split(" ").map(e => parseInt(e));
    let bs = input[2].trim().split(" ").map(e => parseInt(e));

    let sum = 0;
    for (let i = 0; i < N; i++) {
        const left = Math.min(as[i], bs[i]);
        as[i] -= left;
        const right = Math.min(as[i + 1], bs[i] - left);
        as[i + 1] -= right;
        sum += left + right;
    }
    console.log(sum);
}

main(require("fs").readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 47816
// https://atcoder.jp/contests/abc170/tasks/abc170_c
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int x, n, tmp;
	cin >> x >> n;
	set<int> p;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		p.insert(tmp);
	}
	int ans = 0;
	int diff = 1e7;
	for (auto a:p) {
		if (p.count(a-1) == 0) {
			if (abs(a-1-x) < diff) {
				diff = abs(a-1-x);
				ans = a-1;
			}
		}
		if (p.count(a+1) == 0) {
			if (abs(a+1-x) < diff) {
				diff = abs(a+1-x);
				ans = a+1;
			}
		}
	}
	if (n == 0) {
		cout << x << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi d(n);
	REP(i,n) cin>>d[i];
	
	llong sum=0;
	REP(i,n-1)for(int j=i+1;j<n;++j){
		if(i==j){}
		else{
			int tmp=d[i]*d[j];
			sum+=tmp;
		}
	}
	
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    int h=ty-sy,w=tx-sx;
    vector<char> s;
    rep(i,h)cout<<"U";
    rep(i,w)cout<<"R";
    rep(i,h)cout<<"D";
    rep(i,w)cout<<"L";
    cout<<"D";
    rep(i,w+1)cout<<"R";
    rep(i,h+1)cout<<"U";
    cout<<"L";
    cout<<"U";
    rep(i,w+1)cout<<"L";
    rep(i,h+1)cout<<"D";
    cout<<"R"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
    int N;
    char S[100000];
    int i;
    int c=0;
    scanf("%d%s", &N, S);
    for(i=0;i<N;i++){
        if((i+1<N)&&(S[i]!=S[i+1])){
            c++;
            i++;
        }
    }
    printf("%d\n", c);
    return 0;

}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    int x,n,i,y;
    vector<int> vec;
    for(i=-1;i<=101;i++){
        vec.push_back(i);
    }
    cin>>x>>n;
    rep(i,n){
        cin>>y;
        rep(j,vec.size()){
            if(y==vec[j]){
                vec.erase(vec.begin()+j);
            }
        }
    }
    int d,minv,ans;
    rep(i,vec.size()){
        if(i==0){
            minv=abs(vec[i]-x);
            ans=-1;
        }else{
            d=abs(vec[i]-x);
            if(d<minv){
                minv=d;
                ans=vec[i];
            }
        }
    }
    cout<<ans<<endl;
}

long long int series_sum(long long int n){
    long long int ans=0;
    for(long long int i=1;i<=n;i++){
        ans+=i;
    }
    return ans;
}
template <typename T>
T digitsum(T n){
    string s=to_string(n);
    T sum=0;
    T d=1;
    for(T e=0;e<s.length();e++){
        sum+=(n/d)%10;d*=10;
    }
    return sum;
}
template <typename T>
bool isPrime(T n){
    if(n<=1)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    for(T q=3;q*q<=n;q+=2){
        if(n%q==0)return false;
    }
    return true;
}
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    if(n%2==0){
        T tmp = 0;
        while (n % 2 == 0) {
            tmp++;
            n /= 2;
        }
        ret.push_back(make_pair(2, tmp));
    }
    for (T i = 3; i*i <= n; i+=2) {
        if(n%i==0){
            T tmp = 0;
            while (n % i == 0) {
                tmp++;
                n /= i;
            }
            ret.push_back(make_pair( i, tmp));
        }
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}
long long int intpow(long long int x,long long int n){
    long long int ans=1;
    for(int i=0;i<n;i++){
        ans*=x;
    }
    return ans;
}
template <typename T>T intlog(T x){
    string a=to_string(x);
    return a.length()-1;
}
long long int combination(long long int a,long long int b){
    queue<long long int> bunsi,bunbo;
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        bunsi.push(a-i);
        if(b-i>=2)bunbo.push(b-i);
    }
    while(bunsi.size()!=0||bunbo.size()!=0){
        ans*=bunsi.front();
        bunsi.pop();
        if(ans%bunbo.front()==0){
            ans/=bunbo.front();
            bunbo.pop();
        }
    }
    return ans;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 305
#define lson (now<<1)
#define rson ((now<<1)|1)
typedef long long ll;
using namespace std;
int n,m,k;
ll a[maxn];
int vis[maxn];
int can[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll temp1=0;
	for(int i=3;i<=n;i++)
		temp1=(temp1^a[i]);
	ll temp2=a[1]+a[2];
	ll temp3=temp2-temp1;
	
	if(temp3<0)
		return printf("-1\n"),0;
		
	for(int i=0;i<=60;i++)
	{
		if(!((1ll<<i)&temp1))
		{
			vis[i+1]++;
		}
	}
	
	ll anstemp=0;
	for(int i=0;i<=60;i++)
	{
		if((1ll<<i)&temp3)
		{
			if(!vis[i])
				return printf("-1\n"),0;
			else
			{
				can[i]=1;
				anstemp|=(1ll<<(i-1));
			}
		}
	}
	
	if(anstemp>a[1])
		return printf("-1\n"),0;
	
	for(int i=60;i>=0;i--)
	{
		if((1ll<<i)&temp1)
		{
			if(((1ll<<i)+anstemp)<=a[1])
			{
				anstemp+=(1ll<<i);
			}
		}
	}
	if(anstemp==0)
		return printf("-1\n"),0;
	printf("%lld\n",a[1]-anstemp);
}

Measured memory_bytes: 3724
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[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        final int INF = 1<<29;
        int[] dp = new int[n];
        Arrays.fill(dp,INF);

        dp[0] = 0;
        dp[1] = Math.abs(h[0]-h[1]);
        for(int i=2; i<dp.length; i++){
            dp[i] = Math.min(dp[i], dp[i-1] + Math.abs( h[i] - h[i-1] ));
            dp[i] = Math.min(dp[i], dp[i-2] + Math.abs( h[i] - h[i-2] ));
        }
        System.out.println(dp[n-1]);
    }
}

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

#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii >
#define vll vector<ll >
#define cps CLOCKS_PER_SEC
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define print(s) cout<<#s<<" : ";for(auto i:(s))cout<<i<<" ";cout<<"\n";
#define slld(t) scanf("%lld",&(t))
#define sd(t) scanf("%d",&(t))
#define pd(t) printf("%d\n",(t))
#define plld(t) printf("%lld\n",(t))
#define endl "\n"
ld dist(int x1,int y1, int r1, int x2, int y2, int r2)
{
    return max(0.0, sqrt((x1-x2)*1ll*(x1-x2)+(y1-y2)*1ll*(y1-y2))-r1-r2);
}
const int N = 1e3+10;
ld con[N][N];
vector<pair<int,pair<int,int> > > circles={{0,{0,0}}};
ld dist2[N];
bool vis[N];
int main()
{
    int x,y,r;
    int x1,y1,r1;
    int n;
    sd(x),sd(y),sd(x1),sd(y1);
    circles.push_back(mp(x,mp(y,0.)));
    circles.push_back(mp(x1,mp(y1,0.)));
    sd(n);
    rep(i,1,n+1)
    {
        sd(x),sd(y),sd(r);
        circles.pb(mp(x,mp(y,r)));
    }
    for(int i = 1;i<=n+2;i++)
        for(int j = i;j<=n+2;j++)
            con[i][j] = con[j][i] = dist(circles[i].F,circles[i].S.F,circles[i].S.S,circles[j].F,circles[j].S.F,circles[j].S.S);
    set<pair<ld,int> > st;
    const ld inf = 1e18;
    for(int i = 2;i<n+3;i++)
        dist2[i] = inf,st.insert(mp(dist2[i],i));
    int u = 1;
    while(!st.empty())
    {
        vis[u] = 1;
        for(int i = 1;i<=n+2;i++)
            if(!vis[i])
                if(dist2[i] > dist2[u]+con[u][i])
                {
                    st.erase(mp(dist2[i],i));
                    dist2[i] = dist2[u]+con[u][i];
                    st.insert(mp(dist2[i],i));
                }
        u = st.begin()->S;
        st.erase(st.begin());
    }
    cout<<setprecision(10)<<fixed<<dist2[2]<<endl;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.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; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int count = 0;
    while(a >= b) b *= 2, count++;
    while(b >= c) c *= 2, count++;
    if(count <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        list.add(sc.nextInt());
        for(int i = 1;i < 10001;i++){
            if(list.get(i-1) == 0){
                break;   
            }
            System.out.println("Case " + i + ": " + list.get(i-1));
            list.add(sc.nextInt());
        }
    }
}


Measured memory_bytes: 42132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L, R, K=0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> L >> R;
    K = K + R - L + 1;
  }
  cout << K << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;
    char c = S[K-1];
    for (int i = 0; i < S.length(); i++)
    {
        if (c != S[i]) {
            S[i] = '*';
        }
    }
    cout << S << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[100];
	int b,c,d;
	
	scanf("%d",&b);
	
	for(d = 0;d < b;++d){
		scanf("%d",&c);
		a[d] = c;
	}
	for(d = b-1;d >= 0;--d){
		printf("%d",a[d]);
		if(d != 0){
			printf(" ");
		}
	}
	printf("\n");
	
	return(0);
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
constexpr double PI = acos(-1);

int main(){
  using var = long double;
  var a,b,h,m;
  cin>>a>>b>>h>>m;
  var theta_m = 2*PI/60.0*m;
  var theta_h = 2*PI/12.0*h+2*PI/12.0/60*m;
  var theta = abs(theta_m-theta_h);
  // var theta = 2*PI/60*abs(5*h-m);
  cout<<fixed<<setprecision(10);
  cout<<sqrt(a*a+b*b-2.0*a*b*cos(theta))<<endl;
}

void _main(){

  long double a,b,h,m;
  cin>>a>>b>>h>>m;

  auto point1 = [](long double a,long double h){
    return make_pair(a*sin(PI/6.0*h),a*cos(PI/6.0*h));
  };
  auto point2 = [](long double b,long double m){
    return make_pair(b*sin(2.0*PI/60.0*m),b*cos(2.0*PI/60.0*m));
  };

  auto dist = [](auto a,auto b){
    long double xd = a.first-b.first;
    long double yd = a.second-b.second;
    return sqrt(xd*xd+yd*yd);
  };

  cout<<fixed<<setprecision(10);
  auto p1 = point1(a,h);
  auto p2 = point2(b,m);
  dump(p1,p2);
  cout<<dist(p1,p2)<<endl;

}

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

int main() {
  string s;
  getline(cin, s);
  for (int i=0; i<s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z')
      s[i] = s[i] + 32;
    else if (s[i] >= 'a' && s[i] <= 'z')
      s[i] = s[i] - 32;
  }
  cout << s << endl;
}


Measured memory_bytes: 3172
#include<math.h>
#include <stdio.h>
int main(void)
{
	int n,i;
	int x[1000],y[1000];
	double D1=0,D2=0,D3=0,Dinf=0,a = 0, b = 0, c = 0, max = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&y[i]);
	}
	for(i=0;i<n;i++)
	{
		D1 +=abs(x[i]-y[i]);
	}
	for(i=0;i<n;i++)
	{
		a =a+pow(abs(x[i]-y[i]),2);
	}
	D2 = pow(a,1.0/2.0);
	for (i = 0; i<n; i++)
	{
		b =b+ pow(abs(x[i] - y[i]), 3);
	}
	D3 = pow(b, 1.0 / 3.0);
	for (i = 0; i<n; i++)
	{
		c = abs(x[i] - y[i]);
		if (max < c)
		{
			max = c;
		}
	}
	Dinf = max;
	printf("%f\n%f\n%f\n%f\n",D1,D2,D3,Dinf);
	return 0;
}

Measured memory_bytes: 704
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        boolean hasNext() throws IOException {
            if (tokin.hasMoreTokens()) {
                return true;
            } else {
                String s = in.readLine();
                while (s != null && s.length() == 0) {
                    s = in.readLine();
                }
                if (s == null) {
                    return false;
                } else {
                    tokin = new StringTokenizer(s);
                    return true;
                }
            }
        }
    }

    class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    void run() throws Exception {
        Reader in = new Reader();
        Writer out = new Writer();
        int n = in.nextInt();
        int d = 0;
        boolean dd[] = new boolean[3];
        for (int i = 0; i < 3; i++) {
            if (in.nextInt() == in.nextInt()) {
                d++;
                dd[i] = true;
            }
        }
        boolean must = false;
        if (d == 3) {
            must = true;
        }
        for (int i = 0; i < n - 3; i++) {
            if (dd[i % 3] == true) {
                d--;
                dd[i % 3] = false;
            }
            if (in.nextInt() == in.nextInt()) {
                d++;
                dd[i % 3] = true;
            }
            if (d == 3) {
                must = true;
            }
        }
        if (must) {
            out.print("Yes");
        } else {
            out.print("No");
        }
        out.close();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}


Measured memory_bytes: 33028
def add(n, l):
    global dp
    t = 0
    for v in range(1, len(l)):
        y = l[v]
        x = l[v-1]
        while t != y:
            dp[n][t] += y - 1 - x
            t += 1
        t += 1

def add2(n, l):
    global dp2
    t = 0
    for v in range(1, len(l)):
        y = l[v]
        x = l[v-1]
        while t != y:
            dp2[n][t] += y - 1 - x
            t += 1
        t += 1


H,W = [int(_) for _ in input().split()]
s = []
b = []
c = []
for _ in range(H):
    s.append(input())
for i in range(H):
    a = []
    a.append(0)
    for j in range(W):
        if s[i][j] == '#':
            a.append(j+1)
    a.append(W+1)
    b.append(a)
for j in range(W):
    a = []
    a.append(0)
    for i in range(H):
        if s[i][j] == '#':
            a.append(i+1)
    a.append(H+1)
    c.append(a)
dp = [[0 for _ in range(W+2)] for _ in range(H+2)]
dp2 = [[0 for _ in range(H+2)] for _ in range(W+2)]
for i in range(len(b)):
    add(i+1, b[i])
for i in range(W+2):
    for j in range(H+2):
        dp2[i][j] = dp[j][i]
for i in range(len(c)):
    add2(i+1, c[i])
for i in range(H+2):
    for j in range(W+2):
        dp[i][j] = dp2[j][i]
ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        ans = max(ans, dp[i][j])
print(ans-1)


Measured memory_bytes: 184324
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[][] dp = new int[9][10];

		while (true) {

			int n = sc.nextInt();

			if (n == 0) {
				break;
			}
			System.out.println(solve(n));
		}
	}

	static String solve(int n) {
		String ans = "";
		int[] eight = { 0, 1, 2, 3, 5, 7, 8, 9 };
		while (n > 0) {
			ans = eight[n % 8] + ans;
			n /= 8;
		}
		return ans;
	}

	// 素数判定
	static boolean isPrime(long n) {
		if (n == 2)
			return true;
		if (n < 2 || n % 2 == 0)
			return false;

		int i = 3;
		while (i <= Math.sqrt(n)) {
			if (n % i == 0)
				return false;
			else
				i += 2;
		}
		return true;
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}



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

using namespace std;

const auto PI = 3.14159265358979312;

void print(double x) {
	cout << fixed << setprecision(17) << x;
}

int main() {
	double r;
	cin >> r;
	
	auto area = PI*r*r;
	auto circumference = 2*PI*r;
	
	print(area);
	cout << ' ';
	print(circumference);
	cout << endl;
}


Measured memory_bytes: 3264
lst_1 = list(map(int, input().split()))
n, m = lst_1[0], lst_1[1]
lst = []
vec = []
for i in range(n):
    lst_2 = list(map(int, input().split()))
    lst.append(lst_2)

for i in range(m):
    num = int(input())
    vec.append(num)

for i in range(n):
    c = []
    for j in range(m):
        cj = lst[i][j] * vec[j]
        c.append(cj)
    print(sum(c))


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b[2];
  int count = 0;
  cin >> a;
  b[0] = a - a%100;
  b[1] = a%100 - (a%100)%10;
  b[2] = (a%100)%10;
  if(b[0] == 100){
    count++;
  }
  if(b[1] == 10){
    count++;
  }
  if(b[2] == 1){
    count++;
  }
  
  cout << count;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a, b, c;
		int x;
		
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		if(a > b){
			x = b;
			b = a;
			a = x;
		}
		
		if(b > c){
			x = c;
			c = b;
			b = x;
		}
		
		if(a > b){
			x = b;
			b = a;
			a = x;
		}
		
		if(b > c){
			x = c;
			c = b;
			b = x;
		}
		
		System.out.println(a + " " + b + " " + c);
	}

}

Measured memory_bytes: 26284
def main():
    N, M, X = map(int, input().split())
    A = [list(map(int, input().split())) for i in range(N)]
    # print(A)
    total_cost = 1e10
    possible = False
    for i in range(2**N):
        tmp_cost = 0
        rikai = [0]*M
        for j in range(N):
            if ((i >> j) & 1):
                # print(bin(i))
                tmp_cost += A[j][0]
                for k in range(M):
                    rikai[k] += A[j][k+1]
        # print(rikai)
        if min(rikai) >= X:
            possible = True
            total_cost = min(total_cost, tmp_cost)
    
    if possible:
        print(total_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9244
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>

#include <sstream>

using namespace std;



bool isLoadable(int n, int k, vector<int> &w, int maxp){
  // wi(0..n)
  // k??????????????????
  // maxp
  //
  int tmp=0;
  int index=0;
  for(int j=0;j<k;j++){
    tmp = 0;
    while(index < n && tmp + w[index] <= maxp){
      tmp += w[index];
      index++;
    }
  }

  if(index==n){
    return true;
  }else{
    return false;
  }
}

int binary_search(int n, int k, vector<int> &w){
  long long int Max = 100000*10000;
  int left=0;
  int right=Max;
  int mid;
  while(left < right){
    mid = (left+right)/2;
    if(isLoadable(n, k, w, mid)==false){
      left = mid+1;
    }else{
      right = mid;
    }
  }

  if(isLoadable(n, k, w, mid)==false){
    mid++;
  }
  return mid;
}
		   
		   
int main(){
  int n;
  int k;
  vector<int> w;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    w.push_back(tmp);
  }

  // sort(w.begin(), w.end());
  // reverse(w.begin(), w.end());
  int MaxP;
  vector<int> p(k, 0);

  // MaxP = 0;
  // for(MaxP = 10;MaxP<40;MaxP++){
    // cout << MaxP << ": " << isLoadable(n, k, w, MaxP) << endl;
  // }

  int res = binary_search(n, k, w);
  cout << res << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A, B; cin >> A >> B;
	if (A <= 5) {
		cout << 0 << endl;
	} else if (A <= 12) {
		cout << B/2 << endl;
	} else {
		cout << B << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }

int main(){
    ll n,m;
    ll p[100005];
    string s[100005];
    bool ac[100005] = {0};
    ll cnt[100005] = {0};
    cin >> n >> m;
    rep(i,m) cin >> p[i] >> s[i];
    rep(i,m){
        if (s[i] == "AC") ac[p[i]] = 1;
        else{
            if (!ac[p[i]]) cnt[p[i]]++;
        }
    }
    ll A = 0;
    ll W = 0;
    rep(i,n){
        if (ac[i+1]){
            A++;
            W += cnt[i+1];
        }
    }
    cout << A << " " << W << endl;
}


Measured memory_bytes: 7424
h, w = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(10)]


for k in range(10):
    for i in range(10):
        for j in range(10):
            graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j])

shortest_path = list(zip(*graph))[1]
ans = 0
for _ in range(h):
    for a in map(int, input().split()):
        if a == -1:
            continue
        ans += shortest_path[a]
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define MAXN 105
int main()
{char n[100];
int flag;
while(cin>>n)
{
    flag=0;
    for(int i=0;n[i]!='\0';i++)
    {
        if(n[i]-'0'==9)
            flag=1;
    }
    printf("%s\n",flag==1?"Yes":"No");
}
}


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

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        string s[n];
        rep(i,n)cin>>s[i];
        string code[n]={};
        int m = 0;
        rep(i,n){
            int tmp = s[i].length();
            m = max(tmp,m);
        }
        //cout<<m<<endl;
        rep(k,n){
            code[k]=s[k][0];
            int c = 0;
            int kk = s[k].length();
            for(int i=1;i<kk;i++){
                if(s[k][i-1]=='a'||s[k][i-1]=='i'||s[k][i-1]=='u'||s[k][i-1]=='e'||s[k][i-1]=='o'){
                    code[k] += s[k][i];
                }
            }
        }
        int ans = 0;
        int k = 0;
        sort(code,code+n);
        m  = 0;
        rep(i,n){
            //cout<<"i:"<<i<<" code:"<<code[i]<<endl;
            int tmp = code[i].length();
            m = max(tmp,m);
        }
        rep(i,n-1){
            int kk = code[i].length();
            int kkk = code[i+1].length();
            k = 0;
            rep(j,min(kk,kkk)){
                if(code[i][j] == code[i+1][j]){
                    k++;
                   // cout<<"j:"<<j<<" ";
                }
            }
            if(max(kk,kkk)==k)ans=INF;
           // cout<<"i,k:"<<i<<" "<<k<<endl;
            ans = max(ans,k);
        }
        if(ans==INF){
            cout<<-1<<endl;
        }else{
            cout<<ans+1<<endl;
        }
    }
}


Measured memory_bytes: 3092