akhauriyash/Code-Regression huggingface dataset:
l = int(input())
b3_list = []

k = 1
while l != 0:
	b3_list.append((l % (3 ** k)) // (3 ** (k - 1)))
	l -= l % (3 ** k)
	k += 1

#b3_rev = reversed(b3_list)
digit = len(b3_list) # 3の何乗か + 1

n = digit + 1
edges = []
for i in range(1, digit):
	edges.append([i, i + 1, 0])
	edges.append([i, i + 1, 3 ** (i - 1)])
	edges.append([i, i + 1, 3 ** (i - 1) * 2])

if b3_list[-1] == 1:
	edges.append([digit, digit + 1, 0])

elif b3_list[-1] == 2:
	edges.append([digit, digit + 1, 0])
	edges.append([digit, digit + 1, 3 ** (digit - 1)])

for i in range(1, digit):
	base_num = 0
	for j in range(i, digit):
		base_num += b3_list[j] * (3 ** j)
	if b3_list[i - 1] == 0:
		continue
	elif b3_list[i - 1] == 1:
		edges.append([i, n, base_num])
	elif b3_list[i - 1] == 2:
		edges.append([i, n, base_num])
		edges.append([i, n, base_num + 3 ** (i - 1)])

m = len(edges)

print(n, m)
for i in range(m):
	print(*edges[i])


Measured memory_bytes: 3064
n=input().split()
x=int(n[0])
y=int(n[1])
if 1<=x<1000000000 and 1<=y<=1000000000:
	if x>y:
		while y!=0:
			t=y
			y=x%t
			x=t
		print(x)
	else:
		while x!=0:
			t=x
			x=y%t
			y=t
		print(y)


Measured memory_bytes: 5592
program ABC169_D
  integer(8)::M,O,P,k=2,l=1,ans=0
  integer(8),allocatable::A(:)
  double precision::N
  read(*,*)N
  M=dint(N)
  P=M
  O=dint(sqrt(N))
  allocate(A(0:O))
  A=0
  do while(M>1)
     if(mod(M,k)==0) then
        A(k)=A(k)+1
        M=M/k
        if(k>O) then
           A(0)=1
           exit
        end if
     else
        k=k+1
        if(k>O) then
           A(0)=1
           exit
        end if
     end if
  end do
  do i=0,O
     do while(A(i)-l>=0)
        ans=ans+1
        A(i)=A(i)-l
        l=l+1
     end do
     l=1
  end do
  write(*,*)ans
end program ABC169_D

Measured memory_bytes: 10800
#include <cstdio>
#include <cstring>

int main(void)
{
    int n, scnt;
    char ind[100001];
    scanf("%s", ind);
    scanf("%d", &n);

    scnt=strlen(ind);
    for(int i=0, j=0 ; j<scnt ; j++) {
        i='z'+1-ind[j];
        if(ind[j]!='a' && i<=n) {
            n-=i;
            ind[j]='a';
        }
        if(j+1==scnt) {
            ind[j]+=n%26;
            if(ind[j]>'z') ind[j]-='z'-'a'+1;
        }
    }
    printf("%s\n", ind);
    return 0;
}


Measured memory_bytes: 384
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	cin >> n;
	vector<LL> a(n);
	REP(i, n) cin >> a[i];
	map<LL, int> cnt;
	REP(i, n) {
		cnt[a[i]]++;
	}
	bool ans = true;
	if(n%3 != 0) {
		ans = a[0] == 0 and SZ(cnt) == 1;
	} else {
		LL xsum = 0;
		int tmp = 0;
		for(auto&& e : cnt) {
			if(e.S % (n/3)  != 0) {
				ans = false;
			}
			tmp += e.S / (n / 3);
			DEBUG(e.F);
			REP(_,e.S / (n / 3)) xsum ^= e.F;
		}
		DEBUG(xsum);
		if(tmp != 3) {
			ans = false;
		}
		if(xsum != 0) {
			ans = false;
		}
	}
	if(ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
 
int _;

//========================================================================
int a[maxn];
map<int,int>vis;
//========================================================================
int main()
{
    int x,n;
    scanf("%d%d",&x,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        vis[a[i]]=1;
    }
    int ans1=inf,ans2=-inf;
    for(int i=x;i<=10000;i++) 
    {
        if(vis[i]==0) 
        {
            ans1=i;
            break;
        }
    }
    for(int i=x;i>=-1000;i--)
    {
        if(vis[i]==0) 
        {
            ans2=i;
            break;
        }
    }
    if(n==0) printf("%d\n",x);
    else if(abs(ans1-x)<abs(ans2-x)) printf("%d\n",ans1);
    else printf("%d\n",ans2);
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll n;cin >> n;
    vl v(n+2,0);
    rep(i,n)cin >> v[i+1];
    ll ans=0;
    vl info(n+1);
    rep(i,n+1){
        info[i]=abs(v[i+1]-v[i]);
    }
    ans+=abs(v[2]);
    for(int i=2;i<=n;i++){
        ans += info[i];
    }
    cout << ans << endl;
    for(int i=0;i<n-1;i++){
        ans-=info[i+2];
        ans-=abs(v[i+2]-v[i]);
        ans+=info[i];
        ans+=abs(v[i+1]-v[i+3]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define TRACE(x) cout<<#x<<" = "<<x<<'\n'
#define TRACE2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define TRACEA(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define PRINT(arr, n) for (int iDx = 0; iDx < n; iDx++) printf("%d%c", arr[iDx], " \n"[iDx == n-1])
#define SZ(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int cnt[MAXN];

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &x, &y);
		cnt[x]++; cnt[y]++;
	}
	for (int i = 1; i <= N; i++) {
		if (cnt[i]&1) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    sort(A.begin(), A.end());

    ll sum = 0;
    int res = 0;
    for(int i = 0; i < n-1; i++){
        sum += A[i];
        res++;
        if(2*sum < A[i+1]){
            res = 0;
        }
    }
    res++;
    cout << res << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e6+5;
const int inf=1e9;
long fact[size];
void calc(long n){
	fact[0] = 1;
	rep(i,1,n) fact[i] = fact[i-1] * i % mod;
	return;
}
long modcomb(long n, long r){
	n += r;
	if(n < r) return 0;
	long x = (fact[n-r] * fact[r]) % mod;
	long res = 1; int i = 0;
	while( (mod-2) >= (1<<i) ){
		if( (mod-2) & (1<<i) ) (res *= x) %= mod;
		i++; x = x * x % mod;
	}return res * fact[n] % mod;
}
int main(){
	long a,b,c,d; cin>>a>>b>>c>>d;
	calc(size);
	long ans = modcomb(c+1, d+1) - modcomb(a, d+1) - modcomb(c+1, b) + modcomb(a, b);
	cout<<(ans % mod + mod) % mod<<endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h;
    cin >> h;
    int cnt = 0;
    ll ans = 0;

    while(true){
        if(h == 1) break;
        h /= 2;
        cnt += 1;
    }

    for(int i=0; i<cnt+1; i++){
        ans += pow(2,i);
    }
    //cout << cnt << endl;
    cout << ans << endl;
    return 0;
}

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


int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int tm = 0;
  int ts = 0;
  float tc = 0;
  int m = 0;
  int s = 0;
  float c = 0;


  for(int i=0; 100*A*i<=F; i++){
    tm = 0;
    ts = 0;
    tc = 0;
    for(int j=0; 100*A*i+100*B*j<=F; j++){
      for(int k=0; 100*A*i+100*B*j+C*k<=F; k++){
        for(int l=0; 100*A*i+100*B*j+C*k+D*l<=F; l++){
          ts = C*k+D*l;
          tm = ts + 100*A*i+100*B*j;
          tc = ts*100 / (float(tm));

          if(C*k+D*l<=E*(A*i+B*j) && tc > c){
            s = ts;
            m = tm;
            c = tc;
          }
        }
      }
    }
  }

  if((m|s) == 0) cout << 100*A << " " << 0 << endl;
  else cout << m << " " << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;
typedef long long int ll;

int main(void)
{
	int n = 0;
	char c;
	while (1)
	{
		if ((c = getchar()) == '\n')
			break;
		n += int(c - '0');
		if (n >= 9)
			n %= 9;
	}
	if (n == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main(void){
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    
    int ans = 0, cons = 1;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] == a[i]) cons++;
        else {
            if (cons % 2 == 1) ans++;
            cons = 1;
        }
    }
    if (cons % 2 == 1) ans++;
    
    cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
Dictionary = {}
for i in range(N):
        string = "".join(sorted(input()))
        if string in Dictionary:
                Dictionary[string] += 1
        else:
                Dictionary[string] = 1

ans = 0
for i in Dictionary.values():
        count_tmp = i*(i-1)/2
        ans += count_tmp

print(int(ans))

Measured memory_bytes: 17848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Rectangle Made with Bars
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		StringTokenizer st = new StringTokenizer(br.readLine());

		int[] sides = new int[101];

		for (int i = 0; i < 12; i++) {
			sides[parseInt(st.nextToken())]++;
		}

		boolean ans = true;

		for (int i = 1; i < sides.length; i++) {
			if (!(sides[i] == 0 || sides[i] == 4 || sides[i] == 8 || sides[i] == 12)) {
				ans = false;
				break;
			}
		}

		System.out.println(ans ? "yes" : "no");

	} // end main
}

Measured memory_bytes: 24420
#include <queue>
#include <cstdio>
#include <set>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

template<class T>
T gcd(T a, T b){
  if(a > b) swap(a, b);
  if(a == 0) return b;
  return gcd(a, b % a);
}

long long sumup(int n){
  long long ans;
  if(n % 2 == 0){
    ans = n / 2;
    ans *= n + 1;
  }else{
    ans = (n + 1) / 2;
    ans *= n;
  }
  return ans;
}

int main(){
  int n, m;

  while(cin >> n >> m, n + m){
    long long ans = 0;
    long long cnt = 0;
    vector<int> p(m);
    
    REP(i,m) cin >> p[i];

    bool flag = true;
    while(flag){
      flag = false;

      REP(i,m){
	REP(j,m){
	  if(i != j){
	    if(p[i] % p[j] == 0){
	      p.erase(p.begin() + i);
	      flag = true;
	      break;
	    }
	  }
	}
	if(flag) break;
      }

      m = p.size();
    }
    
    ans = sumup(n);
    cnt = n;
    
    REP(i, 1<<m) if(i){
      long long tmp = 1;
      
      REP(j,m) if(i & (1<<j)){
	tmp = (tmp * p[j]) / gcd<long long>(tmp, p[j]);
	
	if(tmp > n) break;
      }

      long long cc = n / tmp;
      long long sum = sumup(cc) * tmp;
      //printf("tmp: %lld cc: %lld sum: %lld\n", tmp, cc, sum);
      
      if(tmp <= n){
	if(__builtin_popcount(i) % 2 == 1){
	  cnt -= cc;
	  ans -= sum;
	}else{
	  cnt += cc;
	  ans += sum;
	}
      }
    }

    if(cnt == 0){
      printf("0.000000\n");
    }else{
      printf("%.6f\n",ans/(double)cnt);
    }
      
  }

  return 0;
}

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

int r, g, b;

void inin (){
  cin >> r >> g >> b;
}

void judge(){
  int a;
  a = r*100 + g*10 + b;
  a%4 == 0 ? cout << "YES" << endl : cout << "NO" << endl;
}

int main (){
  inin();
  judge();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//define
#define itn int //for int typo error
#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 mb  make_pair
#define fi  first
#define se  second
//typedef
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
typedef pair<int, int> pii;
inline int rint(){int x; scanf("%d", &x); return x;}
//can modify here
const ll mod = 1000000007;
//don't ever modify here, a^b % mod function, extended euclid algo, gcd
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll eea(ll a, ll b, ll &x, ll &y){if(!b){x=1,y=0;return a;} ll x1,y1; ll d = eea(b,a%b,x1,y1);x=y1;y=x1-(ll)(a/b)*y1;return d;}
ll gcd(ll a, ll b){ll x; ll y; return eea(a,b,x,y);}


//code here
void solve()
{
    string s1, s2;
    cin >> s1 >> s2;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s1)
        a--;
    else
        b--;
    cout << a << " " << b;
}


int main() {
    //For faster IO, comment out for interative problems
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	sc.nextInt()
	S := sc.next()

	var cnt int
	arr := strings.Split(S, "")
	for i, v := range arr {
		if v == "A" {
			if len(S) > i+1 && arr[i+1] == "B" {
				if len(S) > i+2 && arr[i+2] == "C" {
					cnt++
				}
			}
		}

	}
	fmt.Println(cnt)
}

/* template functions */
var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}


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

int main(){
  int N,M;
  int a,b;
  int *city=NULL;
  
  scanf("%d %d",&N,&M);
  city= (int *)malloc(sizeof(int)*N);
  for(int i=0;i<N;i++){
    city[i]=0;
  }
  if(city==NULL){
    exit(0);
  }
  for(int i=0;i<M;i++){
    scanf("%d %d",&a,&b);
    city[a-1]++;
    city[b-1]++;
  }
  for(int i=0;i<N;i++){
    printf("%d\n",city[i]);
  }
  free(city);
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      int count = 0;
      int n,x;
      String[] lines;

      while(true){

        lines = br.readLine().split(" ");
        n = Integer.parseInt( lines[0] );
        x = Integer.parseInt( lines[1] );
        if( n == 0 && x == 0) break;

        for( int i = 1; i < n-1; i++ ){
          for( int j = i+1; j < n; j++ ) {
            for( int k = j+1; k <= n; k++ ){
              if ( (i + j + k)  > x ) break;
              if ( (i + j + k) == x ){
                count++;
                // System.out.println( i + " " + j + " " + k);
              }
            }
          }
        }
        System.out.println(count);
        count = 0;
      }
    }
  }
}


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


int ketasuu(int N)
{
    if(N < 10) return 1;
    else if(N < 100) return 2;
    else if(N < 1000) return 3;
    else if(N < 10000) return 4;
    else if(N < 100000) return 5;
    else if(N < 1000000) return 6;
    return 7;
}

int keta10(int keta)
{
    int i = 1;
    while(--keta > 0) i *= 10;
    return i;
}

int keta11(int keta)
{
    int i = 1;
    while(--keta > 0) i = 10 * i + 1;
    return i;
}

int getm(int N)
{
    int m;
    while(N > 0)
    {
        m = N % 10;
        N /= 10;
    }
    return m;
}

int get_mn_max(int N)
{
    int M = getm(N);
    int KK = keta10(ketasuu(N)) * M;
    
    if(M > N - KK) M  = N - KK;
    
    return M;
}

int calc_mnN(int m, int n, int N)
{
    int mn = 0, nm = 0;
    
    for(int i = 1; i <= N; ++i)
    {
        int im = getm(i);
        int in = i % 10;
        if(im == m && in == n) ++mn;
        if(im == n && in == m) ++nm;        
        //std::cout << i << " " << im << " " << in << std::endl;
    }
    
    return mn * nm;
}

int calc_mn(int m, int n, int xx_keta)
{
    if(xx_keta == -1)
    {
        return (m == n) ? 1 : 0;
    }
    else if(xx_keta == -2)
    {
        return 0;
    }
    else if(m == n)
    {
        int k12 = keta11(xx_keta+1) + 1;
        return k12 * k12;
    }
    else
    {
        int k11 = keta11(xx_keta+1);
        return k11 * k11;
    }
}


int main()
{
    int N;
    std::cin >> N;
    
    int keta = ketasuu(N);
    int M = get_mn_max(N);
    int ans = 0;

    for(int m = 1; m <= 9; ++m)
    {
        for(int n = 1; n <= 9; ++n)
        {
            int mn_ans;
            /*
            if(m == M && n <= M)
            {
                mn_ans = calc_mnN(m, n, N);
            }
            else if(m < M && n <= M)
            {
                mn_ans = calc_mn(m, n, keta-2);
            }
            else
            {
                mn_ans = calc_mn(m, n, keta-3);
            }
            */
            mn_ans = calc_mnN(m, n, N);
            
            ans += mn_ans;
            //std::cout << "m=" << m << ", n=" << n << ", mn_ans=" << mn_ans << std::endl;

        }
    }
    std::cout << ans;
}


Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    k = int(readline())
    a, b = map(int, readline().split())
    for i in range(a, b + 1):
        if i % k == 0:
            print('OK')
            break
    else:
        print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61736
#include<stdio.h>

int main()
{
	int a, b;
	
  	scanf("%d", &a);
  	scanf("%d", &b);
  
  	if(a==1){
    	if(b==2){
        	printf("3\n");
        }else{
        	printf("2\n");	
        }
    }else if(a==2){
       	if(b==1){
        	printf("3\n");
        }else{
        	printf("1\n");	
        }
    }else{
       	if(b==1){
        	printf("2\n");
        }else{
        	printf("1\n");	
    	}
    }
  return 0; 
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
		{
			A[i] = cin.nextInt();
		}
		int ng = 1;
		long ans = A[0] - 1;
		for(int idx = 1; idx < N; idx++)
		{
			if(A[idx] > ng + 1)
			{
				ans += (A[idx] - 1) / (ng + 1);
				A[idx] = 1;
			}
			else if(A[idx] == ng + 1)
			{
				ng++;
			}
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 7368
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a<b)swap(a,b);
	cout<<(c-1)/a+1;
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {

  var array = (chunk.trim()).split("\n")
  var hen = 3

  for (var i = 1; i < array.length; i ++) {
    var x = array[i].split(" ");
    x.sort(function(d, e) {
      return e - d
    })

    if (Math.pow(x[0], 2) == Math.pow(x[1] , 2) + Math.pow(x[2], 2)) {
      console.log("YES");
    } else
    console.log("NO"); 
  }
})

Measured memory_bytes: 17908
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;

int main()
{
    string a, b;
    cin >> a >> b;
    if(a == "H")
    {
        if(b == "H")
            cout << 'H';
        else
            cout << 'D';
    }
    else
    {
        if(b == "H")
            cout << 'D';
        else
            cout << 'H';
    }
    return 0;
}


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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    char a;
    cin >> a;

    if (a >= 65 && a <= 90)
        cout << "A" << endl;
    else
        cout << "a" << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>

int n, A[50];

int solve(int i, int m) {
  if (m == 0) {
    return true;
  }
  if (i >= n) {
    return false;
  }
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &m);
    if (solve(0, m)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  if(s== "Sunny") cout << "Cloudy" << endl;
  if(s== "Cloudy") cout << "Rainy" << endl;
  if(s== "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N,A,B;
  cin >>  N >> A >> B;

  ll ans;
  if(A%2==B%2){
    ans=(B-A)/2;
  }else{
    ans=min((B+A-1)/2,(2*N-B+1-A)/2);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

int main() {
	int n, p;
	cin >> n >> p;
	VI v(n);
	REP(i, n) { cin >> v[i]; }

	ll a = 0;//0
	ll b = 0;//1
	REPC(x, v) {
		(x % 2 == 0) ? ++a : ++b;
	}

	ll ans = 1;
	REP(i, a) {
		ans *= 2;
	}

	ll tm = 0;
	for (int i = p; i <= b; i += 2) {
		tm += conb(b, i);
	}

	cout << tm * ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n;
  cin >> n;
  int d[3][100001] = {};

  rep(i, 0, n) {
    int kz[3];
    rep(j, 0, 3) cin >> kz[j];
    rep(j, 0, 3) {
      rep(k, 0, 3) {
        if(j != k) {
          d[k][i + 1] = max(d[k][i + 1], d[j][i] + kz[k]);
        }
      }
    }
  }
  int ans = 0;
  rep(i, 0, 3) {
    ans = max(ans, d[i][n]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = (sum(p[0:K])+K)/2
pre = ans
for i in range(1, N-K+1):
    pre -= (p[i-1]-p[i+K-1])/2
    ans = max(pre, ans)
print(ans)


Measured memory_bytes: 32284
#import <Foundation/Foundation.h>
typedef NSInteger Int;
@interface NSNumber (Extension)
-(NSMutableArray*)primeFactors;
@end

@implementation NSNumber (Extension)
-(NSMutableArray*)primeFactors
{
	NSMutableArray *array = [NSMutableArray array];
	Int factor = 0;
	Int factorCount = 0;
	Int n = [self integerValue];
	Int q = n;
	
	if (n == 1) {
		return [NSMutableArray arrayWithArray: @[@{@"factor": @1, @"exponent": @1}]];
	}
	for(Int i=2;i*i<=n;){
		if (q % i == 0) {
			if (i != factor) {
				factor = i;
				factorCount = 1;
			} else {
				factorCount++;
			}
			q /= i;
		} else {
			if (factor > 0) {
				[array addObject: @{@"factor": @(factor), @"exponent": @(factorCount)}];
				factor = 0;
			}
			i++;
		}
	}
	if (q > 1) {
		[array addObject: @{@"factor": @(q), @"exponent": @1}];
	}
	return array;
}
@end
int main() {
	@autoreleasepool{
		Int a,b;
		scanf("%ld %ld",&a,&b);
		if(a==1 || b==1){
			puts("1");
			return 0;
		}
		NSArray *p1 = [@(a) primeFactors];
		NSArray *p2 = [@(b) primeFactors];
		NSMutableSet *s1 = [NSMutableSet set];
		NSMutableSet *s2 = [NSMutableSet set];
		for(NSDictionary *f in p1){
			[s1 addObject:[f objectForKey:@"factor"]];
		}
		for(NSDictionary *f in p2){
			[s2 addObject:[f objectForKey:@"factor"]];
		}
		[s1 intersectSet:s2];
		printf("%lu", [s1 count]+1);
	}
}

Measured memory_bytes: 8988
#include <stdio.h>
int main(void) {
	long long h, ans=0, cnt=1;
	scanf("%lld", &h);
	while(1){
		if(h/2==0)
			break;
		ans+=cnt;
		h/=2;
		cnt*=2;
	}
	printf("%lld", ans+cnt);	
	return 0;
}

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

const int MAXN = 200005;
 
int n, m, ret, a[MAXN], b[MAXN], c[MAXN];
 
int main() {
  cin>>n>>m;
  ret = n;
	for (int i = 1; i <= n; i ++) {
    cin>>a[i];
    c[a[i]]++;
		if (a[i] - c[a[i]] >= 0 && ++b[a[i] - c[a[i]]] == 1)
			ret--;
	}
	while(m--) {
		int x, y; cin>>x>>y;
		if (a[x] - c[a[x]] >= 0 && !--b[a[x] - c[a[x]]])
			ret ++;
		c[a[x]]--;
		a[x] = y;
		c[a[x]] ++;
		if (a[x] - c[a[x]] >= 0 && ++b[a[x] - c[a[x]]] == 1)
			ret --;
		cout<<ret<<'\n';
	}
}

Measured memory_bytes: 3712
s=input()
o1=0
o0=0
e1=0
e0=0
for i in range(0,len(s),2):
  if s[i]=='1': o1+=1
  else: o0+=1
for i in range(1,len(s),2):
  if s[i]=='1': e1+=1
  else: e0+=1
if o1+e0<o0+e1: print(len(s)-(o0+e1))
else: print(len(s)-(o1+e0))

Measured memory_bytes: 66064
#include <iostream>

using namespace std;

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int m=0;
    for(int i=1; i<=b/k; i++)
    {
        m=k*i;
        if(m>=a && m<=b)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    if(m<a || m>b)
    {
        cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3592
from collections import deque
S = deque(input())
Q = int(input())
rev = False
for i in range(Q):
    query = input()
    if query[0] == '1':
        rev = not rev
    else:
        qtype = query[2]
        qstr = query[4]
        if qtype == "1":#先頭
            if not rev:
                S.appendleft(qstr)
            else:
                S.append(qstr)
        else:
            if not rev:
                S.append(qstr)
            else:
                S.appendleft(qstr)
if rev:
    print(*list(S)[::-1],sep="")
else:
    print(*S,sep="")

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

using namespace std;

int main()
{
	long n;
	cin >> n;
	long d0 = 1, d1 = 0, d2 = 0;
	int mod = 1e9 + 7;
	for (int i = 64; i--;) {
		d2 *= 3;
		d2 += d1;
		if (n & 1l << i) {
			d2 += d1;
			d1 += d0;
			d1 %= mod;
		}
		else {
			d0 += d1;
			d0 %= mod;
		}
		d2 %= mod;
	}
	cout << (d0 + d1 + d2) % mod << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = ""
alpha = [50] * 26
alpha2num = lambda c: ord(c) - ord('a') #alphaを数字に 0-25
num2alpha = lambda c: chr(c + 96)#数字をalphaに数字は1-26

for i in range(N):
  S = str(input())
  y = [0] * 26
  for j in range(len(S)):#max 50
    x = alpha2num(S[j])
    #print(x, S[j])
    y[x] += 1
  for j in range(26):
    alpha[j] = min(alpha[j], y[j])
  
for i in range(26):
  numx = alpha[i]
  A = num2alpha(i + 1)
  for j in range(numx):
    print(A, end = "")

Measured memory_bytes: 40048
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    long long n,m,s=0;
    scanf("%lld%lld",&n,&m);
    while(n<=m)
    {
        s++;
        n=n*2;
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long ans = 0;
		for( long i=1; i*i<=N; i++ ){
			if( N%i==0 ){
				ans = N/i;
			}
		}
		String ss = String.valueOf(ans);
		System.out.println(ss.length());
	}
}


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

int main() {
  int N, l, r, i;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += (r - l) +1;
   } 
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

bool hantei(ll a, ll n){
    ll m=n;
    while(m%a==0) m /= a;
    return m%a==1;
}

int main(void){
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=1; i*i<=N; ++i){
        if(N%i==0){
            if(i>1){
                if(hantei(i, N)) ++ans;
            }
            if(i*i<N){
                if(hantei(N/i, N)) ++ans;
            }
        }
    }
    for(ll i=1; i*i<=N-1; ++i){
        if((N-1)%i==0){
            if(i>1) ++ans;
            if(i*i<N-1) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

char get_another_color(char a, char b){
  if (a > b) swap(a, b);
  if (a == 'b') return "gr"[b == 'g'];
  if (a == 'g') return 'b';
  return '#';
}

int solve(string init)
{
  queue<string> Q;
  set<string> vis;
  Q.push(init);
  vis.insert(init);
  int turn = 0;
  while (!Q.empty()){
    queue<string> nQ;
    while (!Q.empty()){
      string state = Q.front();
      Q.pop();
      bool ok = true;
      rep(i, state.size() - 1){
        if (state[i] != state[i + 1]){
          ok = false;
          string nstate = state;
          nstate[i] = nstate[i + 1] = get_another_color(nstate[i], nstate[i + 1]);
          if (vis.find(nstate) != vis.end()) continue;
          vis.insert(nstate);
          nQ.push(nstate);
        }
      }
      if (ok) return turn;
    }
    turn++;
    swap(Q, nQ);
  }
  return -1;
}

int main()
{
  string state;
  while (cin >> state, state != "0"){
    int result = solve(state);
    if (result < 0) puts("NA");
    else printf("%d\n", result);
  }
  return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string o,e;
    cin>>o>>e;
    rep(i,o.size()){
        cout<<o[i];
        if(i<e.size()) cout<<e[i];
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

int x[55],y[55];
int n;

double sq(double d){return d*d;}

double d(double X,double Y){
  double res = 0;
  rep(i,n){
    res = max(res,sqrt(sq(X-x[i])+sq(Y-y[i])));
  }
  return res;
}

double cal(double X){
  double l = 0,r = 1000;
  rep(i,100){
    double ml = (l*2+r)/3,mr = (l+r*2)/3;
    if(d(X,ml) >= d(X,mr))l = ml;
    else r = mr;
  }
  return d(X,l);
}

int main(){
  
  cout << fixed << setprecision(20);
  cin >> n;
  rep(i,n)cin >> x[i] >> y[i];
  double l = 0,r = 1000;
  rep(i,100){
    double ml = (l*2+r)/3,mr = (l+r*2)/3;
    if(cal(ml) >= cal(mr))l = ml;
    else r = mr;
  }
  cout << cal(l) << endl;
  

  return 0;
}


Measured memory_bytes: 3760
#include<iostream>
using namespace std;
int main()
{
    long long n,m,sum;
    while(cin>>n>>m)
    {
        sum=0;
        if(m>2*n)
        {
            sum+=n;
            m-=n*2;
            sum+=m/4;
        }
        else{
            sum+=m/2;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
    [n, a, b] <- (map read . words) <$> getLine
    print $ mod ((pow 2 n) - 1 - comb n a - comb n b) prime

pow :: Int -> Int -> Int
pow x n
    | n == 0 = 1
    | mod n 2 == 0 = pow (mod (x * x) prime) (div n 2)
    | otherwise = mod (x *  pow x (n - 1)) prime

fact :: Int -> Int
fact 1 = 1
fact n = n * fact (n - 1)

comb :: Int -> Int -> Int
comb n r = do
     (denominator n r) * (pow (numerator n r) (prime - 2))

modMul :: Int -> Int -> Int
modMul x y = mod (x * y) prime

denominator :: Int -> Int -> Int
denominator n r = foldl modMul 1 [n - r + 1..n]

numerator :: Int -> Int -> Int 
numerator n r = foldl modMul 1 [2..r]

prime :: Int
prime = 10 ^ 9 + 7


Measured memory_bytes: 31100
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){if(a < b) {a = b; return true;} return false;}
template<class T> inline bool chMin(T& a, T b){if(a > b) {a = b; return true;} return false;}

int main(){
    vector<pair<int, int>> ryouri;
    vector<int> firstRyouri;
    rep(i, 0, 5){
        int temp;
        cin >> temp;
        if (temp % 10 == 0){
            firstRyouri.push_back(temp);
        }else{
            ryouri.push_back(make_pair(temp % 10, temp));
        }
    }
    int sum = 0;
    if (firstRyouri.size() != 0){
        sum = accumulate(begin(firstRyouri), end(firstRyouri), 0);
    }
    if (ryouri.size() != 0){
        sort(begin(ryouri), end(ryouri), greater<pair<int, int>>());

        rep(i, 0, ryouri.size() - 1){
            sum += ryouri[i].second;
            sum += (10 - ryouri[i].first);
        }
        sum += ryouri[ryouri.size() - 1].second;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,n,b,m,M;
  long long t;
  scanf("%d",&n);
  t=0; 
  m=10000000;
  M=-10000000; 
  for(a=1;a<=n;a++){
    scanf("%d",&b);
    t=t+b;
    if(m>b){
      m=b;
    }
    if(M<b){
      M=b;
    }
  }
  printf("%d %d %lld\n",m,M,t);
  return 0;
}

Measured memory_bytes: 1032
#include <iostream>

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  int MAX = 1 << 20;
  int min_cost = MAX;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      min_cost = min(c, min_cost);
    }
  }
  if (min_cost < MAX) {
    cout << min_cost << endl;
  } else {
    cout << "TLE" << endl;
  }
}


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

int main(){
    int n;
    int input;
    int class_room[NMAX][NMAX];
    int class_room_hand[NMAX][NMAX]; // 1 right 2 left 3 both
    int right[NMAX] = {0};
    int left[NMAX] = {0};
    int ans = 0;
    int ans_n = 0;
    while (cin >> n) {
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> input;
                class_room[i][j] = input;
            }
        }
        for (int i = 0; i < n; i++) {
            right[i] = class_room[i][0];
            for (int j = 0; j < n; j++) {
                if (right[i] > class_room[i][j]) {
                    right[i] = class_room[i][j];
                }
                if (left[i] < class_room[j][i]){
                    left[i] = class_room[j][i];
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (right[i] == class_room[i][j]) {
                    class_room_hand[i][j] |= 1;
                }
                if (left[i] == class_room[j][i]){
                    class_room_hand[j][i] |= 2;
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (class_room_hand[i][j] == 3) {
                    ans = class_room[i][j];
                }
            }
        }
        cout << ans << endl;
        ans = 0;
        fill((int*)class_room,(int*)(class_room+NMAX),0);
        fill((int*)class_room_hand,(int*)(class_room_hand+NMAX),0);
        fill(right, right + (sizeof(right) / sizeof*(right)),0);
        fill(left, left + (sizeof(left) / sizeof*(left)),0);
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(B+C > A){
        C = B + C - A;
        cout << C << endl;
    return 0;
    }
    if(B + C <= A){
    C = 0;
    cout << C << endl;
    return 0;
    }
}


Measured memory_bytes: 384
def bisearch(x,L):
    left = 0
    right = len(L)
    
    while left < right:
        mid = (left+right)//2
        
        if L[mid] == x:
            return True
        elif L[mid] > x:
            right = mid
        else:
            left = mid + 1
    
    return False
    

n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

ans = 0
for x in T:
    judge = bisearch(x,S)
    if judge == True:
        ans += 1

print(ans)


Measured memory_bytes: 16716
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        n: Chars,
    }

    let mut num = 0;
    for c in n {
        num += c.to_digit(10).unwrap();
    }

    if num % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3056
#include <iostream>
using namespace std;
int main() {
    // insert code here...
    string s;
    cin >> s;
    string a;
    
    for (int i = 0; i < s.size(); i++){
        if (i%2 == 0){
            a += s.at(i);
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    r,s,p = map(int, input().split())
    t = list(input().rstrip())
    score = []
    for i in t:
        if i == 'r':
            score.append(p)
        if i == 's':
            score.append(r)
        if i == 'p':
            score.append(s)

    res = sum(score)
    for i in range(k, n):
        if t[i] == t[i-k]:
            res -= score[i]
            t[i] = 'u'
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5052
#                               #
    # author : samars_diary #
    # 21-09-2020 │ 11:35:53 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=i() ; b=i()
    if len(a)==len(b)-1 and a == b[:-1]: print('Yes')
    else: print('No')
solve()

Measured memory_bytes: 9012