akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string digits_str;
    cin >> digits_str;
    ll N = digits_str.size();
    vector<ll> digits(N);
    rep(i,0,N) {
        digits[i] = digits_str[i] - '0';
    }
    ll K;
    cin >> K;
    vector<ll> nonzero_cnt(N+1);
    rep(n,1,N+1) {
        nonzero_cnt[n] = nonzero_cnt[n-1] + ((digits[n-1] > 0) ? 1 : 0);
    }
    auto dp = make_vec_nd((ll)0, N+1, K+1);
    rep(n,1,N+1) {
        rep(k,0,K+1) {
            dp[n][k] = 0;
            if (digits[n-1] > 0) {
                if (nonzero_cnt[n-1] == k) {
                    dp[n][k] += 1;
                } else if (nonzero_cnt[n-1] == k-1) {
                    dp[n][k] += digits[n-1] - 1;
                }
            }
            dp[n][k] += dp[n-1][k];
            if (k >= 1) {
                dp[n][k] += 9 * dp[n-1][k-1];
            }
        }
    }
    ll ans = dp[N][K];
    if (nonzero_cnt[N] == K) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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;
    }
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = a; b; a = a * a , b >>= 1){
        if (b & 1) res = res * a;
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in<ll>(), X = in<ll>();
    ll answer = 0;
    RREP(i,N+1){
        if(X >= modpow(2,i+1)-1){
            answer += modpow(2,i);
            X -= modpow(2,i+1)-2;
        }
        X--;
    }
    cout << answer << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
 
void solve(){
    string s;
    cin>>s;
    ll n = s.length();
    for(ll i=0; i<n; i++){
        if(i%2 == 0 && !(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
            print("No");
            ret;
        }
        else if(i%2 == 1 && !(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
            print("No");
            ret;
        }
    }
    print("Yes");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


Measured memory_bytes: 256
N,D = map(int,input().split())
cood_list = [[int(i) for i in input().split()] for i in range(N)]
ans=0
dis_sum=0
for i in range(N):
    for j in range(i+1,N):
        for l in range(D):
            dis_sum += (cood_list[i][l]-cood_list[j][l])**2
        dis_sum = float(dis_sum)
        if dis_sum**(1/2)%1 == 0:
            ans +=1
        dis_sum=0
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 300005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define ROF(i,a,b) for(i=a ; i>=b ; i--)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 20
#define off 1000000
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int a[300005] ;

void f(int x,int n,int k ,int last)
{
    if(x==0) return ;
    for(int i=last ; i>=1 ; i--)
    {
        if( a[i]==0 ) continue ;
        if(a[i]==1){
            a[i] = 0 ;
            last = i-1 ;
        }
        else{
            a[i]-- ;
            for(int j=i+1 ; j<=n ; j++) a[j] = k ;
            last = n ;
        }
        f(x-1,n,k,last) ;
        return ;
    }
}

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d %d",&k,&n) ;

    if(k%2==0)
    {
        printf("%d",k/2) ;
        for(i=1 ; i<n ; i++) printf(" %d",k) ;
        printf("\n") ;
        return 0;
    }

    for(i=1 ; i<=n ; i++) a[i] = (k+1)/2 ;

    f((n/2),n,k,n) ;

    for(i=1 ; i<=n ; i++){
        if(a[i]!=0) printf("%d ",a[i]) ;
        else break ;
    }
    printf("\n") ;

    return 0 ;
}


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



int main(){
    int n;
    cin>>n;
    int ans[n];
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        ans[a-1]=i+1;
    }
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

string s , q , w , e;

int main()
{
	cin >> s;
	for(int i = 0 ; i < 5 ; i++)
		q += s[i];
	for(int i = 6 ; i < 13 ; i++)
		w += s[i];
	for(int i = 14 ; i < 19 ; i++)
		e += s[i];
	cout << q << " " << w << " " << e;
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    s = input()
    w = 0 # W
    e = 0 # E
    for i in range(n):
        if s[i] == 'W':
            w += 1
        else:
            e += 1
    ww = 0
    ee = 0
    ans = n
    for i in range(n):
        if s[i] == 'W':
            w -= 1
        else:
            e -= 1
        
        ans = min(ans, ww + e)

        if s[i] == 'W':
            ww += 1
        else:
            ee += 1

    print(ans)
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""


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

int main() 
{
  //一円 A 合計N 出来る場合yes , no
  int N , A;
  cin >> N >> A;
  
  if (N <= A) {
    cout << "Yes" << endl; 
    return 0;
  }
  
  for (int i = 0; i <= A ; i++) {
    if ((N - i) % 500 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
          
}

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

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  static int a[303030];
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }

  vec lv, sv;
  priority_queue<int, vec, greater<int>> pre;
  priority_queue<int> post;

  int sl = 0, sr = 0;
  for (int i = 0; i < N; i++) {
    pre.push(a[i]);
    post.push(a[2 * N + i]);
    sl += a[i];
    sr += a[2 * N + i];
  }

  lv.push_back(sl);
  sv.push_back(sr);
  int ans = -INF;
  chmax(ans, sl - sr);

  for (int i = 0; i < N; i++) {
    pre.push(a[N + i]);
    post.push(a[2 * N - i - 1]);
    sl += a[N + i] - pre.top();
    sr += a[2 * N - i - 1] - post.top();
    lv.push_back(sl);
    sv.push_back(sr);
    pre.pop();
    post.pop();
  }

  for (int i = 0; i < lv.size(); i++) {
    chmax(ans, lv[i] - sv[N - i]);
  }

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


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

int main(){
	int n;
	while(cin>>n,n!=-1){
		int sum=0;
		while(n>10){
			if(30<n){n--;sum+=160;}
			else if(20<n){sum+=140;n--;}
			else if(10<=n){sum+=125;n--;}
			//cout<<n<<" "<<sum<<endl;
		}
		sum+=1150;
		cout<<4280-sum<<endl;
	}

}

Measured memory_bytes: 1160
#include<stdio.h>
#include<limits.h>
#define WHITE 0
#define BLACK 2
#define GRAY 1

int pa[101];
int A[101][101];
int Cost[101];
int CL[101];
int NT[101];
int cnt;
int sum;
int n;
void DA(int);
int main(){
  int i,j,x,num,d,dis;    
 scanf("%d",&n);
 for(i=0;i<n;i++){
   for(j=0;j<n;j++){
              A[i][j]=-1;
   }
 }
 for(i=0;i<n;i++){
   
       scanf("%d%d",&num,&d);
       for(j=0;j<d;j++){
	 scanf("%d%d",&x,&dis);
	 A[num][x]=dis;
	 
     }
 }
DA(0);

for(i=0;i<n;i++)
  printf("%d %d\n",i,Cost[i]);
return 0;

}
void DA(int x){
int i,mincost,u,j;
for(i=0;i<n;i++){
Cost[i]=INT_MAX;
pa[i]=-1;
CL[i]=WHITE;
}
cnt=0;
NT[cnt++]=x;
CL[x]=WHITE;
    Cost[x]=0;

  
   while(1){
       mincost=INT_MAX;
       for(i=0;i<n;i++){
           
           if(Cost[i]<mincost&&CL[i]!=BLACK){
               mincost=Cost[i];
               u=i;
           
           
           }
       }
       if(mincost==INT_MAX)
       break;
       CL[u]=BLACK;
 
           for(j=0;j<n;j++){
           if(CL[j]!=BLACK&&Cost[u]+A[u][j]<Cost[j]&&A[u][j]!=-1){
               Cost[j]=Cost[u]+A[u][j];
               pa[j]=u;
           }
           
       }
	   /*for(i=0;i<n;i++){
	     printf("%d %d\n",Cost[i],CL[i]);
	     }*/
   }
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a==b&&b==c&&c%2==0){
    cout << -1 << endl;
    return 0;
  }
  int pa,pi,pu;
  int ret = 0;
  while(a%2==b%2&&b%2==c%2&&c%2==0){
    ret++;
    pa = b/2+c/2;
    pi = a/2+c/2;
    pu = a/2+b/2;
    a=pa;b=pi;c=pu;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	string s;
	cin >> s;
	int n = s.size();
	if ((s.substr(n - 7, 7) == "keyence") || (s.substr(0, 1) == "k" && s.substr(n - 6, 6) == "eyence") || (s.substr(0, 2) == "ke" && s.substr(n - 5, 5) == "yence") || (s.substr(0, 3) == "key" && s.substr(n - 4, 4) == "ence") || (s.substr(0, 4) == "keye" && s.substr(n - 3, 3) == "nce") || (s.substr(0, 5) == "keyen" && s.substr(n - 2, 2) == "ce") || (s.substr(0, 6) == "keyenc" && s.substr(n - 1, 1) == "e") || (s.substr(0, 7) == "keyence"))puts("YES");
	else puts("NO");
	ggr
}



Measured memory_bytes: 256
n,m = gets.chomp.split.map &:to_i
l_max = 0
r_min = 10 ** 6

m.times do
  l,r = gets.chomp.split.map &:to_i
  l_max = [l_max, l].max
  r_min = [r_min, r].min
end

puts (l_max..r_min).size


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

int main() {
  int R0, W0, C, R;
  while (cin >> R0 >> W0 >> C >> R, R0) {
    cout << max(0, (int)ceil(1. * (C * W0 - R0) / R)) << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, p[111];
    cin >> n;
    REP(i, n)
    cin >> p[i];

    int res = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
            res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];
int R[100100];
int L[100100];
int Ans[100100];

// returns gcd(a, b)
// x, y will contain the answer for ax + by = gcd(a, b) after the execution
// if answer for ax + by = c is needed,
// check if c % gcd(a, b) == 0
// get (c / gcd(a, b)) * (x, y)

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}

signed main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }
  
  long long  x, y;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      L[i] = Input[0];
    } else {
      L[i] = extGCD(L[i-1], Input[i], x, y);
    }
  }
  for (int i = N-1; i >= 0; i--) {
    if (i == N-1) {
      R[i] = Input[N-1];
    } else {
      R[i] = extGCD(R[i+1], Input[i], x, y);
    }
  }

  int ans = -1;

  for (int i = 0; i < N; i++) {
    if (i == 0) {
      Ans[i] = R[1];
    } else if (i == N - 1) {
      Ans[i] = L[N-2];
    } else {
      Ans[i] = extGCD(L[i-1], R[i+1], x, y);
    }
    ans = max(ans, Ans[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long sum = 0;
        for(long x=1; x<=n; x++) {
            long y = n / x;
            sum += x*y*(y+1)/2;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
#define p(a,n)  for(lli i=0;i<n;i++)cout<<a[i]<<' ';br
#define br          cout<<endl;
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define upar        1000000007
#define fr(i,a,b)   for(int i=a;i<=b;i++)


using namespace std;
float sum;
void solve()
{
    int n,k;
    cin>>n;
    fr(i,1,n)
    {
        cin>>k;
        sum+=1.0/k;
    }
    cout<<1/sum;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

     //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n; cin >> n;
    vector<ll> l(n); rep(i, n) cin >> l[i];
    sort(all(l));
    int ans = 0;
    rep(i, n-2) {
        Rep(j, i+1, n-1) {
            if(l[i] == l[j]) continue;
            Rep(k, j+1, n) if(l[j] != l[k]) if(l[i] + l[j] > l[k]) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

#print(a)
#print(b)

s = 0
aa = 0
bb = 0

p = []
for i in range(1,n+1):
  p.append(i)

import itertools

for v in itertools.permutations(p):
  s += 1
  #print(v)
  if v == a:
    aa = s
  if v == b:
    bb = s
print(str(abs(aa - bb)))


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)

ans = A[0]

if N%2 == 0:
    ans += 2*sum(A[1:(N-2)//2+1])
else:
    ans += 2*sum(A[1:(N-2)//2+1])+A[(N-2)//2+1]

print(ans)

Measured memory_bytes: 105092
#include <iostream>
#include <vector>
#define N 100001

using namespace std;

vector<pair<int, int> > p[N];
bool f[N];

void func(int n, int t) {
    static int d[N];
    if (f[n]) {
        if (d[n] != t) {
            cout << "No";
            exit(0);
        }
        return;
    }
    f[n] = 1;
    d[n] = t;
    for(auto pp : p[n]) func(pp.first, pp.second + t);
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r, t;
        cin >> l >> r >> t;
        p[l].push_back(make_pair(r, t));
        p[r].push_back(make_pair(l, -t));
    }
    for (int i = 1; i <= n; i++) {
        if (!f[i]) func(i, 1);
    }
    cout << "Yes";
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

    int l = 0, r = 1e9;
    while (r - l > 1) {
        int m = (l + r) / 2;
        ll cnt = 0;
        rep(i, n) cnt += (a[i] - 1) / m;
        if (cnt <= k)
            r = m;
        else
            l = m;
    }

    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4364
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}


Measured memory_bytes: 21716
s = str(input())

S=s[::-1]
T=""
while len(T)<=len(S):
	if T+"maerd"==S[:len(T)+5]:
		T=T+"maerd"
	elif T+"remaerd"==S[:len(T)+7]:
		T=T+"remaerd"
	elif T+"esare"==S[:len(T)+5]:
		T=T+"esare"
	elif T+"resare"==S[:len(T)+6]:
		T=T+"resare"
	else:
		break


if S==T:
	print("YES")
else:
	print("NO")


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

int main(void)
{
	int A, B, C, D; cin >> A >> B >> C >> D;
	if (A + B > C + D)cout << "Left" << endl;
	else if(A + B < C + D)cout << "Right" << endl;
	else cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

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

    int q;
    cin>>q;
    vector<int> query(q);
    for (int i = 0; i < q; ++i) cin>>query[i];

    for (auto k : query) {
        queue<int> D, M;
        
        long long numM = 0;
        long long numC = 0;
        
        for (int i = 0; i < n; ++i) {
            if (!D.empty() && D.front() + k <= i) {
                while (!M.empty() && M.front() < D.front()) M.pop();
                numM -= static_cast<int>(M.size());
                D.pop();
            }
            //cout<<numC<<endl;
            
            switch (str[i]) {
                case 'D':
                    D.push(i);
                    break;
                case 'M':
                    numM += static_cast<int>(D.size());
                    M.push(i);
                    break;
                case 'C':
                    numC += numM;
                    break;
                default:break;
            }
        }

        cout<<numC<<endl;
    }

    return 0;
}

Measured memory_bytes: 5264
O=->a{->b{a|b}}
A=->a{->b{a&b}}
X=->a{->b{a^b}}
loop{
	s=gets.chomp
	break if s=='.'
	s=s.tr('+*^','OAX')
	'abcd'.chars{|c|s.gsub!(c,'[%s]'%c)}
	n=gets.to_i
	r=eval(s.tr('abcd','%04d'%n))[0]
	puts '%d %d'%[r,10000.times.count{|i|r==eval(s.tr('abcd','%04d'%i))[0]}]
}


Measured memory_bytes: 8000
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
//int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
//while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

int32_t main(void){
	IOS;
	int a[1000005];
	mem(a);
	in1(n);
	int arr[n];
	rep(i, 0, n)
	{
		cin>>arr[i];
		a[arr[i]]+=1;
	}
	rep(i, 0, 1000005)
	{
		if(!a[i]) continue;
		for(int j = 2*i; j < 1000005; j+=i) a[j] = 0;
	}
	int ans = 0;
	rep(i, 0, 1000005) if(a[i] == 1) ans += 1;
	cout<<ans<<endl;
}

Measured memory_bytes: 13040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	vi v;
	ll n;
	cin>>n;
	ll a[n+2];
	//map<ll, ll> mp;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		//if(i>n/2) mp[i]+=a[i];
	}
	vi b(n+1, 0);
	for(int i=n;i>=1;i--){
		ll op =0;
		for(int j=i;j<=n;j+=i){
			op+=b[j];
		}
		if((op%2)!=(a[i]%2)){
			b[i] = 1;
			//cout<<5;
		}
		//cout<<op<<" ";
	}
	int flag=0;


	if(flag==1) cout<<-1;
	else{
		for(int i=1;i<=n;i++){
			if(b[i]) v.pb(i);
		}
		cout<<v.size()<<"\n";
		for(int i=0;i<v.size();i++){
			cout<<v[i]<<" ";
		}
	}
    return 0;
}


Measured memory_bytes: 5108
s = input()

ans = 0
if s == "SUN":
    ans = 7
elif s == "MON":
    ans = 6
elif s == "TUE":
    ans = 5
elif s == "WED":
    ans = 4
elif s == "THU":
    ans = 3
elif s == "FRI":
    ans = 2
else:
    ans = 1

print(ans)


Measured memory_bytes: 2940
/**
*    created: 30.05.2020 20:59:18
**/
#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() {

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

    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if (m2 - m1 > 0) {
        h2--;
        m2 += 60;
    }
    int ans = 60 * (h2 - h1) + (m2 - m1);
    cout << ans - k << endl;
    return 0;
}

Measured memory_bytes: 3636
h, w = map(int, input().split())
list_S = [ list(input()) for _ in range(h) ]
ans = "Yes"
a = 0
for i in range(h):
    for j in range(w):
        cnt = 0
        if list_S[i][j] == "#":

            if i + 1 >= 0 and i + 1< h and j >= 0 and j < w:
                if list_S[i+1][j] == "#":
                    cnt += 1

            if i - 1 >= 0 and i - 1< h and j >= 0 and j < w:
                if list_S[i-1][j] == "#":
                    cnt += 1

            if i >= 0 and i < h and j + 1 >= 0 and j + 1 < w:
                if list_S[i][j+1] == "#":
                    cnt += 1

            if i >= 0 and i < h and j - 1>= 0 and j - 1 < w:
                if list_S[i][j-1] == "#":
                    cnt += 1
            if cnt == 0:
                ans = "No"

print(ans)


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

const double PI = 3.141592653589;

int main() {
	int h, w, i, j;

	while(true) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;

		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;

	}

	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstring>

using namespace std;

void solve(char t[100])
{
	char x[100], y[100], xh[100], yh[100];
	int count = 1;
	int e = 0;
	int n = 8 * (strlen(t) - 1);
	char s[800][100];
	bool flag = true;
	
	//cout << t << endl;
	
	for(int i = 0; i < strlen(t) - 1; i++){
		for(int j = 0; j <= i; j++){
			x[j] = t[j];
		}
		x[i + 1] = '\0';
		
		for(int j = i; j < strlen(t); j++){
			y[j - i] = t[j + 1];
		}
		y[strlen(t) - i + 1] = '\0';
		//cout << x << " " << y << endl;
		
		for(int j = 0; j < strlen(x); j++){
			xh[j] = x[strlen(x) - j - 1];
		}
		xh[strlen(x)] = '\0';
		
		for(int j = 0; j < strlen(y); j++){
			yh[j] = y[strlen(y) - j - 1];
		}
		yh[strlen(y)] = '\0';
		//cout << xh << " " << yh << endl;
		
		strcpy(s[0 + e], x);
		strcat(s[0 + e], y);
		
		strcpy(s[1 + e], x);
		strcat(s[1 + e], yh);
		
		strcpy(s[2 + e], xh);
		strcat(s[2 + e], y);
		
		strcpy(s[3 + e], xh);
		strcat(s[3 + e], yh);
		
		strcpy(s[4 + e], y);
		strcat(s[4 + e], x);
		
		strcpy(s[5 + e], y);
		strcat(s[5 + e], xh);
		
		strcpy(s[6 + e], yh);
		strcat(s[6 + e], x);
		
		strcpy(s[7 + e], yh);
		strcat(s[7 + e], xh);
		
		e += 8;
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j < i; j++){
			if(!strcmp(s[i], s[j])){
				flag = false;
			}
		}
		if(flag) count++;
		else flag = true;
	}
	cout << count << endl;

}


int main()
{
	int m;
	char t[100];
	
	cin >> m;
	while(m--){
		cin >> t;
		solve(t);
	}
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;

    cin >> n;
    vector<int> vec(n + 1);

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

    for (int j = 1; j <= n; ++j){
        cout << vec[j] << endl;
    }

    return 0;
}


Measured memory_bytes: 1152
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    n = input()
    if n[0] == '7' or n[1] == '7' or n[2] == '7':
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 64680
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC176
{
    class Program
    {
        static void Main(string[] args)
        {
            var NXT = Console.ReadLine().Split().Select(double.Parse).ToArray();
            // var A = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var N = long.Parse(Console.ReadLine());
            //var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();

            Console.WriteLine(Math.Ceiling(NXT[0] / NXT[1]) * NXT[2]);

        }
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

ll solve(ll h) {
  if (h == 1) return 1;
  return 1 + 2LL*solve(h/2);
}

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

ll  h;
  cin >> h;
  cout << solve(h) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

double d(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  double X[N], Y[N];
  vector<int> idx(N);
  FOR(i,0,N) {
    cin >> X[i] >> Y[i];
    idx[i] = i;
  }

  double ans = 0;
  double cnt = 0;
  do {
    cnt++;
    FOR(i,0,N-1) {
      ans += d(X[idx[i]], Y[idx[i]], X[idx[i+1]], Y[idx[i+1]]);
    }
  } while (std::next_permutation(idx.begin(), idx.end()));

  cout << std::fixed << std::setprecision(15) << ans / cnt << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt(), w = in.nextInt(), d = in.nextInt();
        List<Grid> list = new ArrayList<>();
        list.add(new Grid(0, 0, 0));
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                list.add(new Grid(in.nextInt(), i, j));
            }
        }
        list.sort(Comparator.comparing(Grid::getA));
        int[] cost = new int[h * w + 1];
        for (int k = 1; k <= d; k++) {
            cost[k] = 0;
            for(int i = k + d; i < cost.length; i += d) {
                cost[i] = cost[i - d]
                        + Math.abs(list.get(i).getX() - list.get(i - d).getX())
                        + Math.abs(list.get(i).getY() - list.get(i - d).getY());
            }
        }
        int q = in.nextInt();
        for (int i = 0; i < q; i++) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(cost[r] - cost[l]);
        }
    }
}

class Grid {
    int a;
    int x;
    int y;
    public Grid(int a, int x, int y) {
        this.a = a;
        this.x = x;
        this.y = y;
    }

    public int getA() {
        return a;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
}


Measured memory_bytes: 101408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();

		System.out.println(calculatePatty(N, X));

	}

	public static long calculateBurgerLayerNum(int N) {
		return (long) (Math.pow(2, N + 2) - 3);
	}

	public static long calculatePattyNum(int N) {
		return (long) Math.pow(2, N + 1) - 1;
	}

	public static long calculatePatty(int N, long X) {
		if (X <= N) {
			return 0;
		}
		if (N == 0) {
			return X > 0 ? 1 : 0;
		}

		long burgerLayerNum = calculateBurgerLayerNum(N);
		long burgerLayerHalfNum = burgerLayerNum / 2;
		if (X < burgerLayerHalfNum) {
			long patty = calculatePatty(N - 1, X - 1);
			return patty;
		} else if (X == burgerLayerHalfNum) {
			long pattyNum = calculatePattyNum(N - 1);
			return pattyNum;
		} else if (X == burgerLayerHalfNum + 1) {
			long pattyNum = calculatePattyNum(N - 1);
			return pattyNum + 1;
		} else {
			long patty = calculatePatty(N - 1, X - burgerLayerHalfNum - 1);
			long pattyNum = calculatePattyNum(N - 1);
			return patty + 1 + pattyNum;
		}

	}

}

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

using namespace std;
using ll = long long;
constexpr int LOGNMAX = 35;

ll pow3[LOGNMAX];

// 1 = right, 0 = both, -1 = left
vector<ll> closestLanders(ll xc, ll yc, ll sqSize, int goalSide, ll offset) {
//	printf("CL %lld %lld %lld %lld\n", xc, yc, sqSize, (ll)goalSide);
	if (sqSize == 1) return {offset, offset};
	ll subRange = sqSize / 3;
	int subX = xc / subRange, subY = yc / subRange;
//	printf("subBlock %d %d\n", subX, subY);
	if (subX == 1) {
		if ((subY == 0 && goalSide != -1) || (subY == 2 && goalSide != 1)) {
			return {subRange - 1 + offset, 2 * subRange + offset};
		} else {
//			printf("ADD OFFSET %lld\n", subRange);
			return closestLanders(xc % subRange, yc % subRange, subRange, goalSide, offset + subRange);
		}
	} else {
//		printf("ADD OFFSET %lld\n", xc / subRange * subRange);
		return closestLanders(xc % subRange, yc % subRange, subRange, (goalSide + 1 == subY ? goalSide : 0),
				offset + (xc / subRange * subRange));
	}
}

ll solve(ll xa, ll ya, ll xb, ll yb, ll sqSize) {
//	printf("solving %lld %lld %lld %lld %lld\n", xa, ya, xb, yb, sqSize);
	if (sqSize == 1) return 0;
	ll subRange = sqSize / 3;
	ll abx = xa / subRange, aby = ya / subRange;
	ll bbx = xb / subRange, bby = yb / subRange;
//	printf("subblocks %lld %lld %lld %lld\n", abx, aby, bbx, bby);
	if (abx == bbx && aby == bby) {
		return solve(xa % subRange, ya % subRange, xb % subRange, yb % subRange, subRange);
	}
	// are they locked in the y=1|y=1 case?
	if (aby == 1 && bby == 1) {
		swap(xa, ya); swap(xb, yb); swap(abx, aby); swap(bbx, bby);
	}
	if (abx == 1 && bbx == 1) {
//		printf("run around hole case %lld %lld %lld %lld\n", xa, ya, xb, yb);
		return abs(yb - ya) + min(xa + xb - 2 * (subRange - 1), 4 * subRange - xa - xb);
	}
	// do they need closestLanders treatment?
	if (abx == bbx || aby == bby) {
		if (aby == bby) {
			swap(xa, ya); swap(xb, yb); swap(abx, aby); swap(bbx, bby);
		}
		if (ya > yb) {
			swap(xa, xb); swap(ya, yb); swap(abx, bbx); swap(aby, bby);
		}
//		printf("solving bridge case %lld %lld %lld %lld %lld\n", xa, ya, xb, yb, sqSize);
		ll ans = 1e18; 
//		printf("using for first side: %d\n", (bby - aby == 2 ? 0 : 1));
		vector<ll> clList1 = closestLanders(xa % subRange, ya % subRange, subRange, (bby - aby == 2 ? 0 : 1), 0);
		vector<ll> clList2 = closestLanders(xb % subRange, yb % subRange, subRange, -1, 0);
		for (ll px1 : clList1) {
			for (ll px2 : clList2) {
//				printf("checking CL pair %lld %lld\n", px1, px2);
				ans = min(ans, abs(yb - ya) + abs(px1 - px2) + abs(xa % subRange - px1) + abs(xb % subRange - px2));
			}
		}
		return ans;
	}
	// default case
	return abs(xb - xa) + abs(yb - ya);	
}

int main() {
	pow3[0] = 1;
	for (int i = 1; i < LOGNMAX; ++i) pow3[i] = pow3[i-1] * 3;
	int q; scanf("%d", &q);
	for (int qta = 0; qta < q; ++qta) {
		ll xa, ya, xb, yb; scanf("%lld %lld %lld %lld", &xa, &ya, &xb, &yb);
		printf("%lld\n", solve(xa - 1, ya - 1, xb - 1, yb - 1, pow3[30]));
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> b(n,0),w(n,0);
    rep(i,n){
        if(s[i]=='#') b[i]=1;
        else w[i]=1;
    }
    vector<int> sb(n+1,0),sw(n+1,0);
    rep(i,n){
        sb[i+1]=sb[i]+b[i];
        sw[i+1]=sw[i]+w[i];
    }

    int ans=n;
    rep(i,n+1){
        ans=min(ans,sb[i]+sw[n]-sw[i]);
    }

    cout<<ans<<endl;
}


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

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S.substr(i, 3) == "ABC") cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
int a;
  scanf("%d",&a);
  if(a%2==0){
    printf("%lf\n",1.0/2);
  }else{
    if(a==1){
      printf("%lf\n",1.0);
    }else{
  		printf("%lf\n",((a/2)+1.0)/(a));
    }
	}
}

Measured memory_bytes: 128
import bisect as bs
import math as m
a,b,x = map(int,input().split())
l = 0
r = m.pi/2
for _ in range(10000):
    s = (l+r)/2
    ts = m.tan(s)
    if a*ts < b:
        boundary = a*a*b-a*a*a*ts/2
        if x > boundary:
            r = s
        else:
            l = s
    else:
        boundary = a*b*b/(ts*2)
        if x > boundary:
            r = s
        else:
            l = s
print(l*180/m.pi)

Measured memory_bytes: 9356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

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

int main() {
  int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No") << "\n";
}


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

int main()
{
  int x;
  cin>>x;
  
  int m=0,n=0;
  if(x<500)
   goto end;
  
  m = x/500;
  x = x%500;
  
  end:
  n = x/5;
  
  m = m*1000;
  n = n*5;
  
  cout<<m+n;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
 
int main() {
    int ans = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

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

      int cost = 0;
      int prev = 0;
      for(int i = 1; i <= n; i++) {
        spots[i] = sc.nextInt();
        cost += Math.abs(spots[i] - prev);
        prev = spots[i];
      }
      cost += Math.abs(prev);
      
      for(int i = 1; i < spots.length; i++) {
        prev = spots[i-1];
        int next = spots[0];
        if(i < n) {
          next = spots[i+1];
        }
        System.out.println(cost - Math.abs(spots[i] - prev) - Math.abs(spots[i] - next) + Math.abs(prev - next));
      }
      
  }
}

Measured memory_bytes: 71080
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N;
  cin >> N;
  int ans = 0;
  vector<vector<int>> houseki(2, vector<int>(N));
  for (int j = 0; j < 2; j++) {
    for (int i = 0; i < N; i++) {
      int p;
      cin >> p;
      houseki[j][i] = p;
    }
  }
  for (int i = 0; i < N; i++) {
    if (houseki[0][i] - houseki[1][i] > 0) {
      ans += houseki[0][i] - houseki[1][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
/* ITP1_11_A:Dice I */
/* 20181125 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define M 101

typedef struct {
	int E;
	int W;
	int S;
    int N;
	int top;
	int down;
} Dir;

int main(void) {
	Dir dir = {3, 4, 2, 5, 1, 6};
	char cmd[M];
	int Dice[6];
	int i, temp;

	for(i = 0; i < 6; i++) scanf("%d", Dice + i);
	scanf("%s", cmd);

	i = 0;
	while(cmd[i]) {
		temp = dir.top;
		switch(cmd[i++]) {
			case 'E'  : 
				dir.top = dir.W;
				dir.W = dir.down; 
				dir.down = dir.E;
				dir.E = temp;
				break;
			case 'W' : 
				dir.top = dir.E;
				dir.E = dir.down;
				dir.down = dir.W;
				dir.W = temp; 
				break;
			case 'S'  : 
				dir.top = dir.N;
				dir.N = dir.down; 
				dir.down = dir.S;
				dir.S = temp;
				break;
			case 'N'  : 
				dir.top = dir.S; 
				dir.S = dir.down;
				dir.down = dir.N;
				dir.N = temp; 
				break;
			default   : break;
		}
	}

	printf("%d\n", Dice[dir.top - 1]);

	return 0;
}


Measured memory_bytes: 2112
#include<iostream>

using namespace std;

int main()
{
	int H;
	int W;

	// ???????????????
	while (1)
	{
		// ??\???
		cin >> H >> W;

		if (H == 0 && W == 0)
		{ // ??\?????±???0?????´??????????????????
			break;
		}

		// ????????????
		for (int cnth = 0; cnth < H; cnth++)
		{
			// ?¨?#??????
			if (cnth == 0 || cnth == H - 1)
			{ // ????§???????????°?????????´????????¨???#??§?????????
				for (int cntw = 0; cntw < W; cntw++)
				{
					cout << "#";
				}
			}
			else
			{ // ????§???????????°??????\????????´???
				for (int cntw = 0; cntw < W; cntw++)
				{
					if (cntw == 0 || cntw == W - 1)
					{ // 1?????????????°???????#??????
						cout << "#";
					}
					else
					{ // 1?????????????°?????????\??????"."??????
						cout << ".";
					}
				}
			}
			// ?????????????¬??????????#or.??????
			cout << endl;
		}
		// 1???????????????
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152