akhauriyash/Code-Regression huggingface dataset:
class Heap():
    def __init__(self, numlist):
        self.datas = numlist
        self.size = len(numlist)
        self.buildMaxHeap()

    def maxHeapify(self, i):
        if i > self.size:
            return
        
        l = i * 2 + 1
        r = i * 2 + 2
        max_index = i

        if l < self.size and self.datas[l] > self.datas[max_index]:
            max_index = l
        if r < self.size and self.datas[r] > self.datas[max_index]:
            max_index = r
        
        if max_index != i:
            self.datas[max_index], self.datas[i] = self.datas[i], self.datas[max_index]
            self.maxHeapify(max_index)
    
    def buildMaxHeap(self):
        index = self.size // 2
        while index >= 0:
            self.maxHeapify(index)
            index -= 1

    def show(self):
        print(' ' + str(self.datas).replace(',', '').replace('[', '').replace(']', ''))


if __name__ == '__main__':
    n = input()
    numlist = [int(num) for num in input().split(' ')]
    maxheap = Heap(numlist)
    maxheap.show()


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

int main(){
  int N,ans;
  cin>>N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  ans=0;
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin>>C.at(i);
  }
  
  for(int i=0;i<N;i++){
    ans+=B.at(A.at(i)-1);
    if(i<N-1&&A.at(i)+1==A.at(i+1)){
      ans+=C.at(A.at(i)-1);
    }
  }  
  cout<<ans<<endl;
}

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

int main()
{
    long long n, k;
    cin >> n >> k;
    map<long long, long long> m;
    for(int i=0; i<n; i++){
        long long a, b;
        cin >> a >> b;
        m[a] += b;
    }
    
    long long counter = 0;
    for(auto itr = m.begin(); itr!= m.end(); itr++){
        if(counter + itr->second >= k){
            cout << itr->first;
            return 0;
        }
        counter += itr->second;
    }
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
const int N=100100;
int x,y,n,clk;
vector<int>vec,ans,g[N];
void dfs(int x,int fa=-1){
	int dfn=++clk,sz=g[x].size();
	if (sz==1&&fa!=-1){
		vec.push_back(clk);
		return;
	}
	int id=0;
	for (int j:g[x])
		if (j!=fa){
			if ((int)g[j].size()>1){
				if (id&&(int)g[id].size()>1)return;
				if (id)dfs(id,x);
				id=j;
			}
			else if (!id)id=j;
			else dfs(j,x);
		}
	vec.push_back(dfn);
	dfs(id,x);
}
void NO(){
	puts("-1");
	exit(0);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int cnt=0;
	for (int i=1;i<=n;i++){
		int tmp=0;
		for (int j:g[i])
			if ((int)g[j].size()>1)tmp++;
		if (tmp<=1&&(n==2||(int)g[i].size()>1)){
			cnt++;
			if (cnt>=3)NO();
			vec.clear();
			clk=0;
			dfs(i);
			if ((int)vec.size()==n){
				if (ans.empty())ans=vec;
				else ans=min(ans,vec);
			}
			for (int j:g[i])
				if ((int)g[j].size()==1){
					vec.clear();clk=0;
					dfs(j);
					if ((int)vec.size()==n){
						if (ans.empty())ans=vec;
						else ans=min(ans,vec);
					}
					break;
				}
		}
	}
	if (ans.empty())NO();
	for (int i=0;i<n;i++)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 14968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ.Volume0
{
    class Program0009
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int> results = new Queue<int>();

            while ((input = Console.ReadLine()) != null)
            {
                int n = int.Parse(input);

                results.Enqueue(GetPrimeNumbersNum(n));
            }

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }

        }

        static int GetPrimeNumbersNum(int n)
        {
            bool[] isPrime = new bool[n + 1];

            //初期化
            isPrime[0] = false;
            isPrime[1] = false;
            for (int i = 2; i <= n; i++)
                isPrime[i] = true;


            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    int current = i * 2;

                    while (current <= n)
                    {
                        isPrime[current] = false;
                        current += i;

                    }
                }
            }

            return isPrime.Count(b => b);
        }
    }
}

Measured memory_bytes: 7456
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
//#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;


int main(void){
    const int MAX = 100000;
    int n, k;
    int W[MAX];
    int mid;
    int left = 0;
    int right = 100000 * 10000;
    int windex = 0;
    int pindex = 0;

    //input starts
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", W + i);
    //input ends

    //solve starts
    
    while (right - left > 1) {
        mid = (left + right) / 2;
        int sum = 0;
        while (windex < n && pindex < k){
            if (sum + W[windex] <= mid) {
                sum += W[windex];
                windex++;
                // printf("windex = %d\n", windex);
            } else {
                sum = 0;
                pindex++;
                // printf("pindex = %d\n", pindex);

            }
        }
        if (windex == n){
            right = mid;
            windex = 0;
            pindex = 0;
        } else {
            left = mid;
            windex = 0;
            pindex = 0;
        }
    }
    //solve end
    
    printf("%d\n", right);
    return 0;
}

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

using namespace std;

#define all(x) begin(x), end(x)

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

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

    int n;
    cin >> n;
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;

        if (x == 1) ++a;
        else if (x == 2) ++b;
        else ++c;
    }

    vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, 0.0)));

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n; ++k) {
                if (i + j + k == 0)
                    continue;

                double full = i + j + k;
                double ev = n / full - 1.0;
                dp[i][j][k] = ev;
                if (i and j < n)
                    dp[i][j][k] += i / full * (1.0 + dp[i - 1][j + 1][k]);
                if (j and k < n)
                    dp[i][j][k] += j / full * (1.0 + dp[i][j - 1][k + 1]);
                if (k)
                    dp[i][j][k] += k / full * (1.0 + dp[i][j][k - 1]);
            }
        }
    }

    cout << setprecision(10) << fixed << dp[c][b][a] << '\n';
    
    return 0;
}


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

int main()
{
    vector<int> vec(3);
    for(int i=0;i<3;i++)cin>>vec.at(i);
    sort(vec.begin(),vec.end());
    for(int i=0;i<2;i++)cout<<vec.at(i)<<" ";
    cout<<vec.at(2)<<endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数
class union_find{
    vector<long> parent, tree_size;
    public:
    union_find(long n) : parent(n), tree_size(n,1){
        for(int i=0;i<n;i++) parent.at(i)=i;
    }
    long find(long x){
        while(parent.at(x)!=x) x=parent.at(x)=parent.at(parent.at(x));
        return x;
    }
    bool marge(long a,long b){
        a=find(a);
        b=find(b);
        if(a==b) return false;
        if(tree_size.at(a)<tree_size.at(b)) swap(a,b);
        tree_size.at(a)+=tree_size.at(b);
        parent.at(b)=a;
        return true;
    }
};



int main() {
    
    
    //入力
    long H,W;
    cin>>H>>W;
    vector<vector<char>> s(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>s.at(i).at(j);
        }
    }
    
    
    //計算
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s.at(i).at(j)=='.')  continue;
            if(i>0 && s.at(i-1).at(j)=='#') continue;
            if(i+1<H && s.at(i+1).at(j)=='#') continue;
            if(j>0 && s.at(i).at(j-1)=='#') continue;
            if(j+1<W && s.at(i).at(j+1)=='#') continue;
            
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    //出力
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull long long int
#define float long double
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout<<" x is "<<x<<"\n"
using namespace std;

//inline size_t key( int a,int b,int c,int d) {return a*b*c*d-7707;}
//unordered_map<size_t,bool >vismap;


/*int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */  // 2 Direction
/*int dx[] = {1,0} , dy[] = {0,1};     */  // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction
/*
struct myClass{

    int sum;
    int x;
    int y;

    bool operator < (myClass t) const{
        return sum<t.sum;
    }

};
 */
/*
ll fast_expo(ll a,ll b,ll m){
	if(b==0){
		return 1;
	}
	else{
		ll x=fast_expo(a,b/2,m);
		x*=x;
		x%=m;
		if(b%2==0){
			return x;
		}
		else{
			return (x*a)%m;
		}
	}
}

ll inverse(ll a,ll m){
	return fast_expo(a,m-2,m);
}
*/

/*

void prime_precomputation(vector<ll> &primes,int n){
	vector<int> v(n+10,0);
	v[0]=1;v[1]=1;
	for(int i=2;i*i<=n;i++){
		if(v[i]==0){
			for(int j=2*i;j<=n;j+=i){
				v[j]=1;
			}
		}
	}


}

*/

/*
void FTdfs(int src,vector<vector<int> > &adj, vector<int > & vis,stack<int> &Ftime){
	vis[src]=1;
	for(int i=0;i<adj[src].size();i++){
		int x=adj[src][i];
		if(vis[x]==0){
			FTdfs(x,adj,vis,Ftime);
		}
	}
	Ftime.push(src);
}

void dfs(int src,vector<vector<int> > &adj,vector<int> &vis ,int sc){
	vis[src]=1;
	um[src]=sc;
	scc[sc].pb(src);
	for(int  i=0;i<adj[src].size();i++){
		int x=adj[src][i];
		if(vis[x]==0){
			dfs(x,adj,vis,sc);
		}
	}
}

*/

/*

vector<pair<int,int> > compress(vector<int> &v){
	sort(v.begin(),v.end());
	int n=v.size();
	int cnt=0;
	vector<pair<int,int> > ret;
	for (int i=0;i<n;i++){
		if (i>0&&ar[i]!=ar[i-1]){
			ret.push_back(make_pair(ar[i-1],cnt));
			cnt=0;
		}
		cnt++;
	}
	ret.push_back(make_pair(ar[n-1],cnt));
	return ret;
}






*/

int main(){
	 fast
    cout<<fixed;
    cout<<setprecision(10);
    int q;
   // cin>>q;
    q=1;
    while(q--){
     ll n;
      cin>>n;
      vector<ll> v(n);
      for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]-=i;
        v[i]--;
      }
     sort(ALL(v));

     if(n&1){
        ll ans=0;
        for(int i=0;i<n;i++){
            ans+=abs(v[i]-v[n/2]);
        }
        cout<<ans<<"\n";
     }
     else{
        ll ans=0,x=v[n/2];
        for(int i=0;i<n;i++){
            ans+=abs(v[i]-x);
        }
        cout<<ans<<"\n";
     }
    }
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  ll ok=0;
  if(w/2==x&&h/2==y) ok=1;
  cout<<std::setprecision(10)<<w*h/2<<' '<<ok<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int cards[201] = { 0 };
	int Temp[201] = { 0 };
	int temp;
	int i,j;
	int n,m,k,l;
	int keika;
	
	scanf("%d",&n);
	for(i=1;i<=n*2;i++){
		cards[i]=i;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&k);
		if(k==0){												//OÌ
			for(j=1;j<201;j++){
				Temp[j]=cards[j];
			}
			for(j=1,temp=1;j<=n*2;j+=2,temp++){
				cards[j]=Temp[temp];
			}	
			for(j=2;j<=n*2;j+=2,temp++){
				cards[j]=Temp[temp];
			}
		}														//±±ÜÅ
		else{													//else
			for(j=1;j<=k;j++){
				Temp[j]=cards[j];
			}
			for(j=1;k<=n*2;k++,j++){
				cards[j]=cards[k+1];
			}
			for(l=1,j-=1;j<=n*2;j++,l++){
				cards[j]=Temp[l];
			}
		}												//±±ÜÅB
	}
	for(i=1;;i++){
		if(cards[i]==0){break;}
		printf("%d\n",cards[i]);
	}
	
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long dp[300][300],sum[300][300];
long long a[300];
long long n,l,r;
int main()
{
    for(int i=0;i<=200;i++)
    {
        sum[0][i]=0;
        sum[i][0]=1;
        sum[i][i]=1;
    }
    for(int i=0;i<=200;i++)
    {
        for(int j=0;j<=200;j++)
        {
            dp[i][j]=-1;
        }
    }
    dp[0][0]=0;
    cin>>n>>l>>r;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<=i&&j<=r;j++)
        {
            long long x=dp[i-1][j];
            long long y=dp[i-1][j-1]+a[i];
            if(x==y)
            {
                dp[i][j]=x;
                sum[i][j]=sum[i-1][j]+sum[i-1][j-1];
            }
            else if(x>y)
            {
                dp[i][j]=x;
                sum[i][j]=sum[i-1][j];
            }
            else
            {
                dp[i][j]=y;
                sum[i][j]=sum[i-1][j-1];
            }
        }
    }
    int pos=0;
    long long k=0;
    for(int i=l;i<=r&&i<=n;i++)
    {
        if(pos==0)
        {
            pos=i;
            k=sum[n][i];
        }
        else if(dp[n][i]*pos>dp[n][pos]*i)
        {
            pos=i;
            k=sum[n][i];
        }
        else if(dp[n][i]*pos==dp[n][pos]*i)
        {
            k+=sum[n][i];
        }
    }
    printf("%.6f\n",dp[n][pos]*1.0/pos*1.0);
    cout<<k<<endl;
    return 0;
}

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

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int i, O = 0, l = 0;
	char *S = (char *)malloc(sizeof(char) * 100001);
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){
		if(S[i] == '0'){
			O++;
		}
		else{
			l++;
		}
	}
	printf("%d\n", 2 * min(O, l));
	return 0;
}

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

int main(){
  int n,x,y;
  cin>>n>>x>>y;
  int a[n];
  rep(i,0,n){
    a[i]=0;
  }
  rep(i,1,n){
    rep(j,i+1,n+1){
      if(j<=x){
        a[j-i]++;
      }
      if(i>=y){
        a[j-i]++;
      }
      if(i<=x && y<=j){
        a[x-i+j-y+1]++;
      }
      if(x<i && j<y){
        a[min(j-i,i-x+y-j+1)]++;
      }
      if(i<=x && x<j && j<y){
        a[min(j-i,x-i+y-j+1)]++;
      }
      if(x<i && i<y && y<=j){
        a[min(j-i,j-y+i-x+1)]++;
      }
    }
  }
  rep(i,1,n){
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(n==1) cout<<a[0];
  else{
    sort(a,a+n);
    int s=0,i=0;
    while(k--){
      s+=a[i];
      i++;
    }
    cout<<s;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int N,K;
  cin>>N>>K;
  double ANS  =0;
  for (int i = 1; i <= N; i++)
  {
    double T = double(K)/double(i);
    // DEBUG(T);
    if(T <= 1)
    {
      ANS += 1/double(N);
      continue;
    }
    ANS += 1/pow(2,(int)ceil(log2(T)))/double(N);
  }
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 384
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	string s;
	cin >> s;
	for (int i = 0; i < 3; ++i) {
		if (s[i + 1] == s[i]) {
			cout << "Bad\n";
			return;
		}
	}
	cout << "Good\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

i64 dp[111][4][4][4];

int main() {
    constexpr i64 mod = 1000000007;
    i64 n;
    std::cin >> n;
    constexpr int A = 0, C = 1, G = 2, T = 3;
    memset(dp, 0, sizeof dp);

    for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) {
        bool flg = (i == C && j == G && k == A) || (i == C && j == A && k == G) || (i == G && j == C && k == A);
        if (flg) continue;
        dp[2][i][j][k] = 1;
    }
    for (int i = 3; i < n; i++) {
        for (int j1 = 0; j1 < 4; j1++) {
            for (int j2 = 0; j2 < 4; j2++) {
                for (int j3 = 0; j3 < 4; j3++) {
                    bool cflg = (j3 == A && j2 == G) || (j3 == A && j1 == G) || (j1 == G && j2 == A) || (j1 == A && j2 == G);
                    if (!cflg) dp[i][C][j1][j2] += dp[i - 1][j1][j2][j3];
                    if (j1 != C || j2 != A) dp[i][G][j1][j2] += dp[i - 1][j1][j2][j3];
                    dp[i][A][j1][j2] += dp[i - 1][j1][j2][j3];
                    dp[i][T][j1][j2] += dp[i - 1][j1][j2][j3];

                    for (int c = 0; c < 4; c++) dp[i][c][j1][j2] %= mod;
                }
            }
        }
    }

    i64 ret = 0;
    for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) {
        ret = (ret + dp[n - 1][i][j][k]) % mod;
    }
    std::cout << ret << std::endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int ans=0;
  int k=0,g=0;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    if(A%2 ==0 ) g+=1;
    else k+=1;
  }
  ans=pow(3,N)-pow(2,g)*pow(1,k);
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;


    void calc()
    {
        int N = cin.nextInt();
        int ans = N * 800 - N / 15 * 200;
        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);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 11092
using System;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var set = new HashSet<int>();
            foreach (int a in A) set.Add(a);

            Console.WriteLine(N == set.Count ? "YES" : "NO");
        }
    }
}


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

string S;
int K;

int main() {
  cin >> S >> K;
  vector<string> vec;
  for (int i = 0; i < S.size(); ++i) {
    for (int j = 1; j <= K; ++j) {
      string tmp = S.substr(i, j);
      vec.push_back(tmp);
    }
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec[K-1] << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>

int n,x,a[210],i,f,b[5];

int main(){
	scanf("%d",&n);
	while(n!=0){
		memset(a,0,sizeof(a));
		b[0]=b[1]=n;f=1;
		for(i=0;i<n;i++)scanf("%d",&x),a[x]=1;
		while(b[0]>0 && b[1]>0){
			for(i=1;i<=n*2;i++){
				if(a[i]==f){
					a[i]=2;
					b[f]--;
					f=(f)?(0):(1);
				}
				if(b[0]==0 || b[1]==0)break;
			}
			f=(f)?(0):(1);
		}
		printf("%d\n%d\n",b[0],b[1]);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		ArrayList<Integer> bPoints = new ArrayList<>();
		bPoints.add(0);
		for(int i=0;i<n;i++) {
			a[i] =sc.nextInt();
			if(a[i]==0) {
				bPoints.add(i);
			}
		}
		bPoints.add(n);
		long ans =0;
		for(int i=0;i<bPoints.size()-1;i++) {
			long tempSum =0;
			for(int j=bPoints.get(i);j<bPoints.get(i+1);j++) {
				tempSum+=a[j];
			}
			tempSum/=2;
			ans+=tempSum;
		}
		System.out.println(ans);
		
		
		
	}
}


Measured memory_bytes: 60408
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ins = br.readLine().split(" ");
		int n = Integer.parseInt(ins[0]);
		int k = Integer.parseInt(ins[1]);
		int[] w = new int[n];
		int total = 0;
		int maxWeight = 0;
		for(int i = 0; i < n; i++){
			w[i] = Integer.parseInt(br.readLine());
			total += w[i];
			maxWeight = Math.max(maxWeight, w[i]); // ????????§?????§??????????????¨???
		}
		maxWeight = Math.max(maxWeight, total / k); // ??????????????¨?????§???????????§??????????????¨???

		for(;;){
			boolean flag= true;
			int weightTotal = 0; // ????????????
			int track = 0; // ?????????????????????????????°??°
			for(int i = 0; i < n;){
				if(weightTotal + w[i] > maxWeight){
					if(track >= k-1){ // track??????????????????1??°??????
						flag = false; // ????????°???false?????????
						break; // ?????´???for???????????????
					}
					weightTotal = 0; // ???????????????0?????????
					track++; // ???????????????1??°?????????
					continue; // ????????????????\?????¶???????
				}else{
					weightTotal += w[i]; // ?????????????????????????????????????????????
						i++; // ?¬?????????????
				}
			}
			if(flag == true) break; // ?????????????????????????????£??????????????????????°?????????????????????????
			maxWeight++; // ???????????????1?¢???????
		}
		System.out.printf("%d\n", maxWeight);
	}
}

Measured memory_bytes: 35460
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0,sum=0;
int main(){
	cin >> s;
	if(s.size()==1){
		cout << s;
	}else{
		for(int i=1;i<s.size();i++){
			if(s[i]-48==9){
				++cnt;
			}
		}
		if(cnt==s.size()-1){
			for(int i=0;i<s.size();i++){
				sum+=(s[i]-48);
			}
			cout << sum;
		}else{
			sum+=s[0]-49;
			sum+=(s.size()-1)*9;
			cout << sum;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
vv64 dp;
// v64 fact;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,x;
    cin >> n >> x;
    ll a[n];
    forn(i,n) cin >> a[i];
    sort(a,a+n);
    dp.resize(n+5,vector<ll>(x+5,0));
    // fact.resize(n+5);
    // fact[0]=1;
    // forsn(i,1,n+1){
    // 	fact[i]=fact[i-1]*i;
    // 	fact[i]%=MOD;
    // }
    forn(j,x+1){
    	dp[0][j]=j%a[0];
    }
    forsn(i,1,n){
    	forn(j,x+1){
    		dp[i][j]=dp[i-1][j%a[i]];
    		dp[i][j]%=MOD;
    		dp[i][j]+=i*dp[i-1][j];
    		dp[i][j]%=MOD;
    		if(dp[i][j]<0) dp[i][j]+=MOD;
    	}
    }
    cout << dp[n-1][x] << ln;
    return 0;
}

Measured memory_bytes: 161792
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
const int INF = 100000000;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool in_range(int a, int b){ return a >= 0 && a < b;}

void bfs(map<int,int> &M, vector<int> &G, vector<string> C, int s){
  int h = C.size(), w = C[0].length();
  queue< pair<int,int> > que;
  que.emplace(s,0);
  while(!que.empty()){
    int p = que.front().first, d = que.front().second;
    que.pop();
    if(M[p])
      G[M[p]-1] = min(d,G[M[p]-1]);
    for(int i = 0; i < 4; ++i){
      int x = p/w + dx[i], y = p%w + dy[i], p_ = x*w + y;
      if(in_range(x,h) && in_range(y,w) && C[x][y] != 'x'){
        que.emplace(p_,d+1);
        C[x][y] = 'x';
      }
    }
  }
}

vector< vector<int> > make_graph(vector<string> &C, vector<int> &D){
  int h = C.size(), w = C[0].length(), n = D.size();
  map<int,int> M;
  for(int i = 0; i < n; ++i){
    M[D[i]] = i+1;
  }
  vector< vector<int> > G(n, vector<int>(n,INF));
  for(int i = 0; i < n; ++i){
    bfs(M,G[i],C,D[i]);
  }
  return G;
}

int main(){
  int w, h;
  while(cin >> w >> h, w){
    vector<string> C(h);
    vector<int> D;
    int s;
    for(int i = 0; i < h; ++i){
      cin >> C[i];
      for(int j = 0; j < w; ++j){
        if(C[i][j] == 'o') s = i*w+j;
        if(C[i][j] == '*'){
          D.push_back(i*w+j);
        }
      }
    }
    D.push_back(s);
    vector< vector<int> > G = make_graph(C,D);
    int n = G.size()-1;
    vector<int> V(n);
    for(int i = 0; i < n; ++i) V[i] = i;
    int ans = INF;
    do{
      int t = 0, v = n;
      for(int i = 0; i < n; ++i){
        t += G[v][V[i]];
        v = V[i];
      }
      ans = min(ans,t);
    }while(next_permutation(V.begin(),V.end()));
    if(ans >= INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,m;cin>>n>>m;
   ll arr[n+1],sum=0;
   for(int i=0;i<n;i++)
   {
    cin>>arr[i];
    sum+=arr[i];
   }
   sum=double(sum);
  double c=ceil(sum/(double(m)*4));
  sort(arr,arr+n);
  ll k=0;
  for(int i=n-1;i>=0;i--)
  {
      if(arr[i]>=c)
      {
        k++;
        if(k>=m) break;
      }

  }
  if(k>=m)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=2e6+5;

ll dp[N];

bool use[N];

int main()
{ 

  IOS;

  ll n,k;
  cin>>n;

  vl a(n);

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

    ll b=0,c=0;

    sort(all(a));

    for(int i=0;i<n;i++){
      if(i&1)b+=a[i];
      else c+=a[i];
    }

    cout<<abs(c-b)<<endl;

return 0;
 
}



Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	bool flag = false;
	if ((A[A.size() - 1] == B[0])&&(B[B.size() - 1] == C[0])) flag = true;
	string S = (flag) ? "YES" : "NO";
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
H,W,N = map(int,input().split())
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli.append((b-n)*(H)+(a-m))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Measured memory_bytes: 173372
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> h(5),a(5),b(5);
  int c=0;
  for (int i=0;i<5;i++){
    cin >> h[i];
    a[i]=(h[i]+9)/10*10;
    b[i]=a[i]-h[i];
  }
  cout << a[0]+a[1]+a[2]+a[3]+a[4]-max({b[0],b[1],b[2],b[3],b[4]})<< endl;
}

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

using namespace std;

string s;

int f(char c)
{
          int kilk=0;
          string x=s;
          while(1)
          {
                    int ok=1;
                    for(int i=0;i<x.size();i++)
                              if(x[i]!=c)
                                        ok=0;
                    if(ok)
                              break;
                    string res="";
                    for(int i=0;i<x.size()-1;i++)
                    {
                               if(i!=x.size()-2 && x[i+1]==c)
                                        res+=c;
                              else
                                        res+=x[i];
                    }
                    kilk++;
                    x=res;
          }
          return kilk;
}

int is[27];

int main()
{
          cin>>s;
          for(int i=0;i<s.size();i++)
                    is[s[i]-'a']++;
          int ans=s.size();
          for(int i=0;i<26;i++)
                    if(is[i])
                              ans=min(ans,f((char)('a'+i)));
          cout<<ans<<endl;
}


Measured memory_bytes: 256
// D.

#include <sstream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	int p[10] = {};
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		p[a] = 1;
	}
	vector<string> dp(n + 1);
	int tbl[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
	for (int d = 9; d >= 1; --d) {
		if (p[d]) {
			for (int i = n; i >= tbl[d]; --i) {
				if (i == n || !dp[i].empty()) {
					string s = dp[i] + char('0' + d);
					if (s.length() > dp[i - tbl[d]].length() || (s.length() == dp[i - tbl[d]].length() && s > dp[i - tbl[d]])) {
						dp[i - tbl[d]] = s;
					}
				}
			}
		}
	}
	cout << dp[0] << endl;
	return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    string a, b, c;
    cin >> a >> b >> c;

    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	double a, s;

	while (1) {
		cin >> a;
		if (cin.eof())	break;

		s = a;
		for (int i = 0; i < 9; i++) {
			if (i % 2 == 0) {
				s += a * 2;
				a *= 2;
			}
			else {
				s += a / 3;
				a /= 3;
			}
		}

		printf("%.8f\n", s);
	}

	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int a[] = {1, 3, 5, 7, 8, 10, 12};
int b[] = {4, 6, 9, 11};
int c[] = {2};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y; cin >> x >> y;
    bool f1 = false, f2 = false;
    for (int i : a) {
      if (x == i) f1 = true;
      if (y == i) f2 = true;
    }
    if (f1 && f2) {cout << "Yes" << endl; return 0;}
    f1 = false, f2 = false;
    for (int i : b) {
      if (x == i) f1 = true;
      if (y == i) f2 = true;
    }
    if (f1 && f2) {cout << "Yes" << endl; return 0;}
    f1 = false, f2 = false;
    for (int i : c) {
      if (x == i) f1 = true;
      if (y == i) f2 = true;
    }
    if (f1 && f2) {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
data = read().split()
m = map(int,data[:-1])
XY = zip(m,m)
C = [0] + [1 * (x == ord('W')) for x in data[-1]]

graph = [set() for _ in range(N+1)]
for x,y in XY:
    graph[x].add(y)
    graph[y].add(x)

deg = [len(x) for x in graph]
b_leaf = [i for i in range(N+1) if deg[i] == 1 and not C[i]]

while b_leaf:
    x = b_leaf.pop()
    for y in graph[x]:
        graph[y].remove(x)
        deg[y] -= 1
        if deg[y] == 1 and not C[y]:
            b_leaf.append(y)
    deg[x] = 0
    graph[x].clear()

V = set(i for i,E in enumerate(graph) if E)
if len(V) <= 2:
    print(sum(C))
    exit()
root = None
for v in V:
    if deg[v] > 1:
        root = v
        break

parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

"""
・Euler tourの状態から、パスをひとつ除く
・葉と葉を結ぶとしてよい。通ると2コスト安くなる点がある
"""

for i in range(N+1):
    C[i] ^= (1&deg[i])

cost_full = sum(deg) + sum(C)

# C[i] == 1 となる i を最もたくさん含むパスを探す

opt = 0
dp = [0] * (N+1)
for v in order[::-1]:
    if deg[v] == 1:
        continue
    arr = sorted((dp[w] for w in graph[v] if w != parent[v]),reverse = True) + [0]
    x = arr[0] + arr[1] + C[v]
    if opt < x:
        opt = x
    dp[v] = arr[0] + C[v]

answer = cost_full - 2 * opt
print(answer)

Measured memory_bytes: 59776
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
        ll t,n,m,i,a,b;
        cin>>a>>b;
        
        cout<<(a*b)/__gcd(a,b);
 }
    


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int n, l;
    VI as;
    int a;
    cin >> n >> l;
    REP(i,n) {
        cin >> a;
        as.push_back(a);
    }
    vector<int> rev;
    REP(i,n-1) {
        if (as[i] + as[i+1] >= l) {
            break;
        } else {
            rev.push_back(as[i]);
        }
    }
    if (rev.size() == as.size() - 1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    REP(i,rev.size()) {
        cout << i + 1 << endl;
    }
    for (int i = n - 1; i >= int(rev.size() + 1); i--) {
        cout << i << endl;
    }
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#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++)

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  
  cout<<c/a*b<<endl;
}
            

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n;
        while((n= scanner.nextInt()) != 0) {
            int data[] = new int[n];
            for(int i = 0; i < n; i++){
                data[i] = scanner.nextInt();
            }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += data[i];
        }
        double m = (double)sum / n;
        double a2 = 0;
        for (int i = 0; i < n; i++){
            double d = data[i] - m;
            a2 += d*d;
        }
        a2 /= n;
        double a = Math.sqrt(a2);
        System.out.println(a);
        }
    }   
}


Measured memory_bytes: 30872
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
st = 0
sx = 0
sy = 0
ans = 'Yes'
for i in range(n):
    t, x, y = na()
    dt = abs(st - t)
    dx = abs(sx - x)
    dy = abs(sy - y)
    if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
        st, sx, sy = t, x, y
        continue
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 5148
#include<iostream>

using namespace std;

int input,oturi,output; 

int main(){
	while(1){
		oturi=0;
		output=0;
		cin>>input;
		if(input==0) break;
		oturi=1000-input;
		if(oturi>=500){
			output+=oturi/500;
			oturi-=oturi/500*500;
		}
		if(oturi>=100){
			output+=oturi/100;
			oturi-=oturi/100*100;
		}
		if(oturi>=50){
			output+=oturi/50;
			oturi-=oturi/50*50;
		}
		if(oturi>=10){
			output+=oturi/10;
			oturi-=oturi/10*10;
		}
		if(oturi>=5){
			output+=oturi/5;
			oturi-=oturi/5*5;
		}
		if(oturi>=1){
			output+=oturi/1;
			oturi-=oturi/1*1;
		}
		cout<<output<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;

typedef pair<int, pair<int, int> > p;

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

	int N, K, S;

	cin >> N >> K >> S;

	for(int i = 0; i < K; i++) {
		cout << S << " ";
	}

	for(int i = 0; i < N - K; i++) {
		cout << 1036 << " ";
	}
}


Measured memory_bytes: 1280
#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;
    cin >> n;
    int a[3 * n];
    rep(i, 3 * n) cin >> a[i];
    sort(a, a + 3 * n, greater<int>());

    ll ans = 0;
    rep(i, n) ans += a[i * 2 + 1];

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


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

int main()
{
    int a;
    cin >>a;
    int ans;
    for(int i=1; ;i++)
    {
        if((a*i)%360==0)
        {
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632