akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void computeLPSArray(string pat, int M, int* lps); 
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}
vector<int> KMPSearch(string pat, string txt) 
{ 
	int M = pat.length(); 
	int N = txt.length(); 
	vector<int> ans ;
	// create lps[] that will hold the longest prefix suffix 
	// values for pattern 
	int lps[M]; 

	// Preprocess the pattern (calculate lps[] array) 
	computeLPSArray(pat, M, lps); 

	int i = 0; // index for txt[] 
	int j = 0; // index for pat[] 
	while (i < N) { 
		if (pat[j] == txt[i]) { 
			j++; 
			i++; 
		} 

		if (j == M) { 
			ans.push_back(i - j) ;
			j = lps[j - 1]; 
		} 

		// mismatch after j matches 
		else if (i < N && pat[j] != txt[i]) { 
			// Do not match lps[0..lps[j-1]] characters, 
			// they will match anyway 
			if (j != 0) 
				j = lps[j - 1]; 
			else
				i = i + 1; 
		} 
	} 
	return ans ;
} 

// Fills lps[] for given patttern pat[0..M-1] 
void computeLPSArray(string pat, int M, int* lps) 
{ 
	// length of the previous longest prefix suffix 
	int len = 0; 

	lps[0] = 0; // lps[0] is always 0 

	// the loop calculates lps[i] for i = 1 to M-1 
	int i = 1; 
	while (i < M) { 
		if (pat[i] == pat[len]) { 
			len++; 
			lps[i] = len; 
			i++; 
		} 
		else // (pat[i] != pat[len]) 
		{ 
			// This is tricky. Consider the example. 
			// AAACAAAA and i = 7. The idea is similar 
			// to search step. 
			if (len != 0) { 
				len = lps[len - 1]; 

				// Also, note that we do not increment 
				// i here 
			} 
			else // if (len == 0) 
			{ 
				lps[i] = 0; 
				i++; 
			} 
		} 
	} 
} 
//check modulo
int main(){
	IOS;
	cout.precision(30) ;
	string s ,t ; cin >> s >> t;
	int nb = 0 ;
	for(int i = 0 ; i < 3  ;i++) nb += (s[i] == t[i]) ;
	cout << nb << endl ;
				
			
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef int i;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  lli a,x;
  cin>>a;
  x=a+(a*a)+(a*a*a);
  cout<<x<<"\n";
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int ans = 0;

    // 区切り
    for (int i = 1; i < n; i++)
    {
        map<char, int> left;
        map<char, int> right;
        int count = 0;

        // 文字
        for (int j = 0; j < n; j++)
        {
            if (j < i)
            {
                if (left.count(s[j]) == 0)
                {
                    left.insert(make_pair(s[j], 1));
                }
            }
            else
            {
                if (left.count(s[j]) != 0)
                {
                    if (right.count(s[j]) == 0)
                    {
                        right.insert(make_pair(s[j], 1));
                        count++;
                    }
                }
            }
        }
        
        ans = max(count, ans);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

#define REP(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

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

    int K;
    cin >> K;
    cout << K / 2 * (K / 2 + K % 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int dp[114514];
int a[114514],b[114514];
signed main(){
	ic(h) ic(n)
	rep(0,i,n)cin>>a[i]>>b[i];
	dp[h]=0;
	for(int i=h-1;i>=0;i-=1){
		int tyousa[114514];
		rep(0,j,n)tyousa[j]=dp[i+a[j]]+b[j];
		dp[i]=mini(tyousa,0,n);
	}
	c(dp[0])	
}	

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll a, b;
    ll k[1005] = {};
    
    k[0] = 1;
    for(ll i = 1; i < 1003; i++){
        k[i] = k[i - 1] + i + 1;
    }
    
    cin >> a >> b;
    REP(i, 1001){
        if(a < k[i] && b < k[i + 1]){
            if(k[i] - a == k[i + 1] - b){
                cout << k[i] - a << endl;
                return 0;
            }
        }
    }
}


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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{";
	for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i];
	cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n";
	for (auto& vec : arr)cout << "  " << vec << ",\n";
	cout << "}";
	return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll k;cin >> k;

  if(k % 2 == 0){
  	cout << -1 << '\n';
  	return 0;
  }

  ll ten = 1;
  ll tmp = 0;
  int cnt = 1;
  for(int i = 0;i < k;i++){
  	ll add = (7 * ten) % k; 
  	tmp = (tmp + add) % k;
  	ten = (ten * 10) % k;
  	if(tmp == 0){
  		cout << cnt << '\n';
  		return 0;
  	}
  	cnt++;
  }
  cout << -1 << '\n';

}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long A[N + 1];
    long B[N + 1];
    for (int i = 1; i <= N - 1; ++i) cin >> B[i];
    B[N] = B[N - 1];
    for (int i = 1; i <= N - 1; ++i) A[i + 1] = min(B[i], B[i + 1]);
    A[1] = max(A[2], B[1]);
    long long total = 0;
    for (int i = 1; i <= N; ++i) total += A[i];
    cout << total << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
ans = len(s)
for i in range(0, 2):
    cnt = 0
    for j in range(0, len(s)):
        if j % 2 == 0 and s[j] != str(i): cnt += 1
        if j % 2 == 1 and s[j] == str(i): cnt += 1
    ans = min(ans, cnt)
print(ans)



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

int main(){
	ll n;
	cin>>n;
	string s;
	while(n != 0){
		if(n%2 != 0){
			s = "1"+s ;
			n--;
		}else{
			s = "0" +s;
		}
		n /= -2;
	}
	if(s == "")s = "0";
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int slen = s.length();
  int las = slen - 1;
  int ans = 0;
  int j = las;
  bool fin = false;
  for (int i = 0; i < slen; i++) {
    if (i < las && s.at(i) == 'R') continue;
    for(; j >= 0; j--) {
      if (j <= i) {fin = true;break;}
      if (s.at(j) == 'R') {
        s.at(j) = 'W';
        s.at(i) = 'R';
        ans++;
        j--;
        break;
      }
    }
    if (fin) break;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3736
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(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 (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main()
{
    int k, t;
    cin >> k >> t;
    pair<int, int> a[105];
    int b;
    rep(i, t)
    {
        cin >> b;
        a[i] = make_pair(b, i);
    }
    int tmp = -1;
    int ans = 0;
    rep(i, k)
    {
        sort(a, a + t);
        reverse(a, a + t);
        //cout << i << endl;
        if (tmp != a[0].second) {
            a[0].first--;
            //cout << a[0].second << endl;
            tmp = a[0].second;
        } else if (a[1].first > 0) {
            //cout << a[1].second << endl;
            a[1].first--;
            tmp = a[1].second;
        } else {
            //cout << a[0].second << endl;
            a[0].first--;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <utility>
  
#define YNUM(X) ( X < 0 ? X + 3 : X )
  
int h, w;
bool map[502][502];
char in[502];
int data[3][502][502];
int data_max = 0;
int height_sum[502][502], width_sum[502][502];

int main(){
    while( std::cin >> h >> w, w + h != 0 ){
        data_max = 0;
  
        memset( height_sum, 0, sizeof(height_sum) );
        memset( width_sum, 0, sizeof(width_sum) );
  
        for( int i = 1; i <= h; ++i ){
            std::cin >> in;
            for( int l = 1; l <= w; ++l ){
                map[i][l] = ( in[l - 1] == '.' );
                if(map[i][l]){
                    width_sum[i][l] = width_sum[i][l - 1] + 1;
                    height_sum[i][l] = height_sum[i - 1][l] + 1;
                }
            }
        }
  
        for( int i = 1, n = 1; n <= h; n++, i = n % 3 ){
            for( int l = 1; l <= w; l++ ){
                memset( data[i][l], 0, sizeof(int) * 502 );
                if( map[n][l] ){
                    if( map[n - 1][l] && map[n][l - 1] ){
                        int x_cnt = width_sum[n][l], y_cnt = height_sum[n][l];
  
                        for( int m = 1; m < 502; ++m ){
                            if( data[YNUM(i - 1)][l][m] ){
                                data[i][l][std::min(m, x_cnt)] = std::max( data[i][l][std::min(m, x_cnt)], data[YNUM(i - 1)][l][m] + 1 );
                                data_max = std::max( data_max, std::min(m, x_cnt) * data[i][l][std::min(m, x_cnt)] );
                            }
                        }
                        for( int m = 1; m < 502; ++m ){
                            if( data[i][l - 1][m] ){
                                data[i][l][m + 1] = std::max( data[i][l][m + 1], std::min(data[i][l - 1][m], y_cnt) );
                                data_max = std::max( data_max, (m + 1) * data[i][l][m + 1] );
                            }
                        }
                          
                    }else if( map[n - 1][l] ){
                        for( int m = 0; m < 502; ++m ){
                            if( data[YNUM(i - 1)][l] ){
                                data[i][l][1] = std::max( data[i][l][1], data[YNUM(i - 1)][l][m] + 1 );
                                data_max = std::max( data_max, data[i][l][1] );
                            }
                        }
  
                    }else if( map[n][l - 1] ){
                        for( int m = 1; m < 502; ++m ){
                            if( data[i][l - 1][m] ){
                                data[i][l][m + 1] = std::max( data[i][l][m + 1], 1 );
                                data_max = std::max( data_max, (m + 1) * data[i][l][m + 1] );
                            }
                        }
  
                    }else data[i][l][1] = std::max( data[i][l][1], 1 ), data_max = std::max( data_max, data[i][l][1] );
  
                }   
            }
        }
  
        std::cout << data_max << std::endl;
    }
    return 0;
}

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

using namespace std;

#define N 1200000
#define ls (x<<1)
#define rs (x<<1|1)

int n,k,a[N],b[N],c[N];

int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;++i){
		a[i]=k+i;
		b[i]=k+n+i;
		c[i]=k+n*2+i;
	}
	if (n&1){
		int x=a[0],y=b[n/2],z=c[0];
		if (x+y>z){puts("-1"); return 0;}
		if (n>1){
			x=a[n/2+1],y=b[0],z=c[1];
			if (x+y>z){puts("-1"); return 0;}
		}
		for (int i=0;i<=n/2;++i){
			int x=a[i],y=b[i+n/2],z=c[i*2];
			printf("%d %d %d\n",x,y,z);
		}
		for (int i=0;i<n/2;++i){
			int x=a[i+n/2+1],y=b[i],z=c[i*2+1];
			printf("%d %d %d\n",x,y,z);
		}
	}
	else{
		int x=a[0],y=b[n/2],z=c[0];
		if (x+y>z){puts("-1"); return 0;}
		for (int i=0;i<n/2;++i){
			int x=a[i],y=b[i+n/2],z=c[i*2];
			printf("%d %d %d\n",x,y,z);
		}
		for (int i=0;i<n/2;++i){
			int x=a[i+n/2],y=b[i],z=c[i*2+1];
			printf("%d %d %d\n",x,y,z);
		}
	}
	
	return 0;
}
			

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] march = new long[5];
		for(int i = 0; i < N; i++) {
			String S = sc.next();
			if(S.charAt(0) == 'M')
				march[0] += 1;
			if(S.charAt(0) == 'A')
				march[1] += 1;
			if(S.charAt(0) == 'R')
				march[2] += 1;
			if(S.charAt(0) == 'C')
				march[3] += 1;
			if(S.charAt(0) == 'H')
				march[4] += 1;
		}
		long ans = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = i+1; j < 4; j++) {
				for(int k = j+1; k < 5; k++) {
					ans += march[i]*march[j]*march[k];
				}
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 46000
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

string EncodeRunLength(string rls){
	string sret;

	for(unsigned int i = 0; i < rls.length(); i++){
		if( rls[i] == '@'){
			int num = rls[i+1]-'0';
			for(int j = 0; j < num; j++) sret += rls[i+2];
			i+=2;
		}else sret += rls[i];
	}

	return sret;
}

int main(void){
	while( true ){
		char buf[128];
		string s;

		if( EOF == scanf("%s",buf) ) break;
		s = buf;

		cout << EncodeRunLength( s ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


bool Hch(int w){

}
int main() {
    int H,W;cin >> H >> W;
    vector<int> mo(4);
    map<char,int> m;
    rep(i,H*W){
        char c;cin >> c;
        m[c]++;
    }
    for(auto t : m){
        int tmp = t.S % 4;
        mo[tmp]++;
    }

    bool ok = true;
    if(H % 2 == 0 && W % 2 == 0){
        if(mo[1] > 0 || mo[2] > 0 || mo[3] > 0)ok = false;
    }
    else if(H % 2 == 1 && W % 2 == 1){
        if(mo[2] > ((H-1)/2 + (W-1)/2))ok = false;
        if(mo[1]+mo[3] != 1)ok = false;
    }
    else{
        if(H % 2 == 0 && mo[2] > H/2)ok = false;
        if(W % 2 == 0 && mo[2] > W/2)ok = false;
        if(mo[1]+mo[3] > 0)ok = false;
    }

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N,K; cin>>N>>K;
    int h[N]; REP(i,N) cin>>h[i];
    int dp[N+K]; REP(i,N) dp[i] = INF;
    dp[0] = 0;
    REP(i,N) {
        REP(j,K) {
            dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]));
        }
    }
    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
from operator import itemgetter
N = int(input())
LR = []
for _ in range(N):
    l, r = map(int, input().split())
    LR.append([l, r+1])
ans = 0
for l, r in LR:
    ans = max(ans, r-l)
LR.sort(key=itemgetter(1))

# 区間スケジューリングの解が 3 以上のとき、
# 2 回とも楽しさが 1 以上になることはないので、
# 最も長い区間の幅がそのまま答えになる

# 解が 2 のときは、2 回とも楽しさが 1 以上になる場合も存在する
# これは、重ならない 2 つの区間を取り出して、
# 他の区間がそのどちらと一緒になるか考えれば良い
# 考えると、ある区間が別の区間を完全に被覆する場合、
# それらは必ず同じグループに含まれることがわかるので、
# 被覆する側の区間（大きい方）は無視できる
# 無視すると、区間の集合が半返し縫いの裏側みたいになるので
# 順に並べてどちらと一緒になるかの境目を全探索すれば良い

# 解が 1 のときは、全ての区間に共通する区間があるので、
# この区間の中の人を除外して考えると、
# 解が 2 の場合に帰着できる

sch = 0
rr = 0
for l, r in LR:
    if l >= rr:
        rr = r
        sch += 1
if sch >= 3:
    print(ans)
    exit()

mid_range = 0
if sch == 1:
    mid_l = 0
    mid_r = float("inf")
    for l, r in LR:
        mid_l = max(l, mid_l)
        mid_r = min(r, mid_r)
    mid_range = mid_r - mid_l  # この値で補正すると区間スケジューリングの解が 2 のときと同じように解ける
    for i in range(N):
        LR[i][1] -= mid_range
    ans += mid_range

# 完全に被覆している区間は狭い方だけ残す
LR_ = []
pl = 0
for l, r in LR:
    if pl < l:
        LR_.append([l, r])
        pl = l
LR = LR_
if len(LR) == 1:
    print(ans)
    exit()

Ll, Lr = LR[0]
Rl, Rr = LR[-1][0], LR[1][1]
ans2 = max(Rr-Rl, 0) + Lr-Ll
for i, (l, r) in enumerate(LR[1:-1], 1):
    Ll = l
    Rr = LR[i+1][1]
    ans2 = max(ans2, max(Rr-Rl, 0) + max(Lr-Ll, 0))
ans2 += mid_range * 2
print(max(ans, ans2))


Measured memory_bytes: 30340
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll a,b,c,d;

int main(){
  ll ans=0;
  cin>>a>>b>>c>>d;

  ans=a*c;
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  ans=max(ans,b*d);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			//var n = Console.ReadLine();
			HashSet<long> hash = new HashSet<long>();
			int N = int.Parse(Console.ReadLine());
			for (int i = 0; i < N; i++)
			{
				long a = long.Parse(Console.ReadLine());
				if (hash.Contains(a)) hash.Remove(a);
				else hash.Add(a);
			}
			Console.WriteLine(hash.Count);
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 22620
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int n;
	scanf("%d", &n);
	vector < int > a(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int x = min(a[i], a[i + 1]);
		a[i] -= x, a[i + 1] -= x;
		if ((a[i] & 1) && x > 0)
		{	
			a[i]++, a[i + 1]++;
			x--;
		}
		ans += x;
		ans += a[i] / 2;
	}
	ans += a[n - 1] / 2;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=128;
char c[66]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int cnt[62],len;
int _;
int ask(string s){
	_++;
	if (_>850){
		assert(false);
	}
	printf("? %s\n",s.c_str());
	fflush(stdout);
	int v;
	scanf("%d",&v);
	return v;
}

string Merge(string A,string B){
	string cur;
	int j=0;
	if (B=="") return A;
	for (int i=0;i<A.size();i++){
		while (j<B.size()){
			string tt=cur;
			tt+=B[j];
			for (int k=i;k<A.size();k++){
				tt+=A[k];
			}
			if (ask(tt)==len-tt.size()){
				cur+=B[j];
				j++;
			}
			else{
				break;
			}
		}
		cur+=A[i];
	}
	while (j<B.size()){
		cur+=B[j];j++;
	}
	return cur;
}
string Solve(int l,int r){
	string cur;
	while (!cnt[l] && l<=r) l++;
	if (l>r) return cur;
	if (l==r){
		for (int i=0;i<cnt[l];i++){
			cur+=c[l];
		}
		return cur;
	}
	int tot=0;
	for (int i=l;i<=r;i++) tot+=cnt[i];
	int cc=0,mid=r;
	for (int i=l;i<=r;i++){
		cc+=cnt[i];
		if (cc*2>=tot){
			mid=i;
			break;
		}
	}
	if (mid==r) mid--;
	string A=Solve(l,mid);
	string B=Solve(mid+1,r);
	return Merge(A,B);
}
int main(){
	for (int i=0;i<62;i++){
		string s;
		for (int j=0;j<128;j++){
			s+=c[i];
		}
		cnt[i]=128-ask(s);
	//	cnt[i]=0;
	//	if (i<=2) cnt[i]=3;
		len+=cnt[i];
	}
	printf("! %s\n",Solve(0,61).c_str()); 
	fflush(stdout);
	return 0;
}

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

int n;

int count(vector<int> &p) {
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i + 1] > p[i] && p[i] > p[i - 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) {
            ans++;
        }
    }

    return ans;
}

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

    int ans = count(p);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  sort(a,a+n);
  pr(a[n-1].F+a[n-1].S);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> " " >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;

    int two=min({Q*8,H*4,S*2,D});
    int one=min({Q*4,H*2,S});
    if(N%2) {
        cout<<(N/2)*two+one<<endl;
    } else {
        cout<<(N/2)*two<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    punch = [[False for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                punch[i][j] = True
    ans = "No"
    for i in range(3):
        if False not in punch[i]:
            ans = "Yes"
            break
        for j in range(3):
            if not punch[j][i]:
                break
        else:
            ans = "Yes"
            break
    if (punch[0][0] and punch[1][1] and punch[2][2]) or (
            punch[0][2] and punch[1][1] and punch[2][0]):
        ans = "Yes"
    print(ans)


resolve()


Measured memory_bytes: 9188
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[50][50][1<<12][4];
char str[50][51];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++)
			if(str[i][j]=='.')str[i][j]='0';
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++)
			for(int k=0;k<(1<<12);k++)
				for(int l=0;l<4;l++)
					dp[i][j][k][l]=-99999999;
	dp[0][0][0][c]=0;
	for(int i=c;i>=0;i--){
		for(int j=0;j<a;j++){
			for(int k=0;k<b;k++){
				for(int l=0;l<(1<<12);l++){
					if(dp[j][k][l][i]<0)continue;
					int R;
					int W;
					bool ok;
					if(j<a-1&&str[j+1][k]!='#'){
						R=0;W=0;ok=true;
						for(int m=0;m<6;m++){
							R-=dx[(l>>(m*2))&3];
							W-=dy[(l>>(m*2))&3];
							if(R==1&&W==0)ok=false;
						}
						if(ok){
							dp[j+1][k][(l<<2)&((1<<12)-1)][i]=max(dp[j][k][l][i]+str[j+1][k]-'0',dp[j+1][k][(l<<2)&((1<<12)-1)][i]);
						}else{
							dp[j+1][k][(l<<2)&((1<<12)-1)][i]=max(dp[j][k][l][i],dp[j+1][k][(l<<2)&((1<<12)-1)][i]);
						}
					}
					if(k<b-1&&str[j][k+1]!='#'){
						R=0;W=0;ok=true;
						for(int m=0;m<6;m++){
							R-=dx[(l>>(m*2))&3];
							W-=dy[(l>>(m*2))&3];
							if(R==0&&W==1)ok=false;
						}
						if(ok){
							dp[j][k+1][((l<<2)+1)&((1<<12)-1)][i]=max(dp[j][k][l][i]+str[j][k+1]-'0',dp[j][k+1][((l<<2)+1)&((1<<12)-1)][i]);
						}else{
							dp[j][k+1][((l<<2)+1)&((1<<12)-1)][i]=max(dp[j][k][l][i],dp[j][k+1][((l<<2)+1)&((1<<12)-1)][i]);
						}
					}
					if(j&&str[j-1][k]!='#'&&i){
						R=0;W=0;ok=true;
						for(int m=0;m<6;m++){
							R-=dx[(l>>(m*2))&3];
							W-=dy[(l>>(m*2))&3];
							if(R==-1&&W==0)ok=false;
						}
						if(ok){
							dp[j-1][k][((l<<2)+2)&((1<<12)-1)][i-1]=max(dp[j][k][l][i]+str[j-1][k]-'0',dp[j-1][k][((l<<2)+2)&((1<<12)-1)][i-1]);
						}else{
							dp[j-1][k][((l<<2)+2)&((1<<12)-1)][i-1]=max(dp[j][k][l][i],dp[j-1][k][((l<<2)+2)&((1<<12)-1)][i-1]);
						}
					}
					if(k&&str[j][k-1]!='#'&&i){
						R=0;W=0;ok=true;
						for(int m=0;m<6;m++){
							R-=dx[(l>>(m*2))&3];
							W-=dy[(l>>(m*2))&3];
							if(R==0&&W==-1)ok=false;
						}
						if(ok){
							dp[j][k-1][((l<<2)+3)&((1<<12)-1)][i-1]=max(dp[j][k][l][i]+str[j][k-1]-'0',dp[j][k-1][((l<<2)+3)&((1<<12)-1)][i-1]);
						}else{
							dp[j][k-1][((l<<2)+3)&((1<<12)-1)][i-1]=max(dp[j][k][l][i],dp[j][k-1][((l<<2)+3)&((1<<12)-1)][i-1]);
						}
					}
				}
			}
		}
	}
	int ret=0;
	for(int i=0;i<=c;i++)
		for(int j=0;j<(1<<12);j++)ret=max(ret,dp[a-1][b-1][j][i]);
	printf("%d\n",ret);
}

Measured memory_bytes: 161024
n=int(input())
x=list(map(int,input().split()))

mas=[False]*2022

for i in x:
    mas[i]=True

m=int(input())
a=list(map(int,input().split()))

for i in range(m):
    now=x[a[i]-1]
    if not mas[now+1] and now!=2019:
        mas[now]=False
        mas[now+1]=True
        x[a[i]-1]+=1

for i in range(2020):
    if mas[i]:
        print(i)


Measured memory_bytes: 5624
import java.util.*;
import java.lang.*;

class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();

        sc.close();
        long ans = 0;
        long g = (C*D) / gcd(C,D);
       // System.out.println(g);
        ans += ((B/C) - ((A-1)/C));        
       // System.out.println(ans);
        ans += ((B/D) - ((A-1)/D));
       // System.out.println(ans);
        ans -= ((B/g) - ((A-1)/g));

        System.out.println((B-A+1) - ans);

    }
    static long gcd (long a, long b){
        long temp;
        while((temp = a%b) != 0){
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
f0, f1, f2 = 0, 0, 0
for i in range(N):
    if a[i] % 4 == 0:
        f2 += 1
    elif a[i] % 2 == 0:
        f1 += 1
    else:
        f0 += 1
if f1:
    if f0 <= f2:
        print('Yes')
    else:
        print('No')
else:
    if f0 <= f2 + 1:
        print('Yes')
    else:
        print('No')

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

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    for (int i = 0; i < k; i++) {
        if (a >= b) {
            b *= 2;
        } else if (b >= c) {
            c *= 2;
        }
    }

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-8
#define lb(x) x & -x
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

const int N = 1050;
const int M = 2050;
const int mod = 1000000007;

struct Edge
{
	int u, v, w;
	bool operator<(const Edge &e) const
	{
		return w < e.w;
	}
}e[M];

int fa[N];

int Find(int x)
{
	if(fa[x]) return fa[x] = Find(fa[x]);
	return x;
}
bool Union(int x, int y)
{
        x = Find(x);
        y = Find(y);
	if (x != y)
	{
		fa[x] = y;
		return 1;
	}
	return 0;
}

ll qp(ll x, int p)
{
	ll ans = 1;
	while(p)
	{
		if(p & 1) ans = x * ans % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return ans;
}

int main()
{
	int n, m;
	ll x;
	n = read();
	m = read();
    x = read1();
	if (n <= 2)
	{
		printf("0\n");
		return 0;
	}
	rep(i, 0, m - 1)
	{
		e[i].u = read();
		e[i].v = read();
		e[i].w = read();
	}
	sort(e, e + m);
	int s1 = 0, s2 = 0;
	rep(i, 0, m - 1)
	{
		memset(fa, 0, sizeof fa);
		ll ans = e[i].w * Union(e[i].u, e[i].v);
		rep(j, 0, m - 1)
			ans += e[j].w * Union(e[j].u, e[j].v);
		if (ans < x) s1 ++;
		if (ans <= x) s2 ++;
	}
	printf("%lld\n", (qp(2, min(m, m - s1 + 1)) - qp(2, min(m, m - s2 + 1)) + mod) % mod);
	return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = (0 until n).map { sc.next() }
    println(problem164c(n, s))
}

fun problem164c(n: Int, s: List<String>): Int {
    val set = mutableSetOf<String>()
    return s.toSet().size
}

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

int main() {
  int a[5],b[5];
  while ( cin >> a[1] >> a[2] >> a[3] >> a[4]
	  >> b[1] >> b[2] >> b[3] >> b[4] ) {
    int h = 0,bb = 0;
    for ( int i = 1; i < 5; i++ ) {
      if ( a[i] == b[i] ) h++;
    }

    for ( int i = 1; i < 5; i++ ) {
      for ( int j = 1; j < 5; j++ ) {
	if ( i != j && a[i] == b[j] ) bb++;
      }
    }
    cout << h << " " << bb << endl;
  }
  return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    int ans=0;
    REP(i,N){
        int c = 0;
        if(s1[i] == s2[i]) c++;
        if(s1[i] == s3[i]) c++;
        if(s2[i] == s3[i]) c++;

        if(c==1) ans += 1;
        else if(c==0) ans += 2;
    }
    
    pl(ans)

    return 0;
}

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

int h,w;
string s[70];
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={0,1,-1,1,-1,1,0,-1};
int dp[72][72];
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      dp[i][j]=0;
    }
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
	for(int e=0;e<8;e++){
	  if(i+dx[e]>=0 && j+dy[e]>=0)dp[i+dx[e]][j+dy[e]]++;
	}
      }
    }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#')cout<<'#';
      else cout<<dp[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper



a, b = inl()
ok = False
for c in range(1, 4):
    if c* a * b %2 == 1:
        ok = True
print('Yes' if ok else 'No')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<string> vc(n);
    for(auto &i:vc)
      cin>>i;
    sort(vc.begin(),vc.end());
    for(auto i:vc)
      cout<<i;
    cout<<endl;
    

    return 0;
}




Measured memory_bytes: 256
import java.io.*;
public class Main {
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};
	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		while (true) {
			int m = Integer.valueOf(s.readLine());
			int n = Integer.valueOf(s.readLine());
			if (m == 0 && n == 0) {
				break;
			}
			int[][] map = new int[n][m];
			for (int i = 0 ; i < n ; i++) {
				String[] data = s.readLine().split(" ");
				for (int j = 0 ; j < m ; j++) {
					map[i][j] = Integer.valueOf(data[j]);
				}
			}
			int max = 0;
			H = n;
			W = m;
			for (int i = 0 ; i < n ; i++) {
				for (int j = 0 ; j < m ; j++) {
					if (map[i][j] == 1) {
						boolean[][] broken = new boolean[n][m];
						max = Math.max(max, dfs(i, j, map, broken));
					}
				}
			}
			out.println(max);
		}
		out.flush();
	}
	static int H;
	static int W;
	private static int dfs(int y, int x, int[][] map, boolean[][] brk) {
		int ret = 0;
		for (int d = 0 ; d < 4 ; d++) {
			int tx = x + dx[d];
			int ty = y + dy[d];
			if (tx < 0 || ty < 0 || tx >= W || ty >= H || map[ty][tx] == 0 || brk[ty][tx]) {
				continue;
			}
			brk[ty][tx] = true;
			ret = Math.max(ret, 1 + dfs(ty, tx, map, brk));
			brk[ty][tx] = false;
		}
		return ret;
	}
}

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

int main() {
  int X;
  cin >> X;
  int c =(X/500);
  int d =c * 1000;
  int m = X - c * 500;
  int s = d + (m/5) * 5; 
  cout << s <<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int		N;
	string	a;
	cin >> N >> a;
	for (auto &i : a)
	{
		if ((int)i + N <= 90)
			i += N;
		else
			i += (N - 26);
	}
	cout << a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
typedef struct{
	int A;
	int B;
}shop_t;

int compare(const void *a,const void *b){
	return ((shop_t *)a)->A-((shop_t *)b)->A;
}

int main(){
	int N,M;
	int i,j;
	int get;
	long long int ans;
	shop_t m;
	
	scanf("%d %d",&N,&M);
	
	shop_t list[N];
	
	for(i=0;i<N;i++){
		scanf("%d %d",&list[i].A,&list[i].B);
	}
	
	qsort(list,N,sizeof(shop_t),compare);
	
	ans=0;
	get=0;
	i=0;
	while(get!=M){
		while(list[i].B==0)	i++;
		
		ans+=list[i].A;
		list[i].B--;
		get++;
	}
	
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec v(N); cin >> v;
    priority_queue<double, vector<double>, greater<double>> que;
    REP(i, N) que.push((double)v[i]);
    REP(i, N - 2){
        double a = que.top(); que.pop();
        double b = que.top(); que.pop();
        que.push((a + b) / 2);
    }
    double a = que.top(); que.pop();
    double b = que.top(); que.pop();
    Out((a + b) / 2.0);

    return 0;
}


Measured memory_bytes: 256