akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b)
    cout<<"Draw";
  else if(a<b && a!=1)
    cout<<"Bob";
  else if(b==1)
    cout<<"Bob";
  else cout<<"Alice";
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main()
{
    string S;
    cin >> S;
    ll N = S.length();
    ll count1 = 0;
    ll count0 = 0;
    rep(i, N) {
        if (S[i] == '1') {
            count1++;
        }else {
            count0++;
        }
    }
    cout << min(count1, count0) * 2 << endl;

    return 0;
}



Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x,y,z,k=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    C=list(map(int,input().split()))
    S=[]
    T=[]
    from itertools import product
    for a,b in product(A,B):
        S.append(a+b)
    S.sort(reverse=1)
    S=S[:k]
    for s,c in product(S,C):
        T.append(s+c)
    T.sort(reverse=1)
    for i in range(k):
        print(T[i])
resolve()

Measured memory_bytes: 138508
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector2(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v){
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

int main(){
    ll n;
    cin>>n;
    ll arr[n+1]={0};
    for(ll i=0;i<n-1;i++){
        ll temp;
        cin>>temp;
        arr[temp]++;
    }
    for(ll i=1; i<=n; i++){
        cout<<arr[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5208
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    int a[N],b[N];
    for (int i=0;i<N;i++){
        cin>>a[i];
        b[a[i]-1]=i+1;
    }
    for(int i=0;i<N-1;i++){
        cout<<b[i]<<" ";
    }
    cout<<b[N-1]<<endl;

}


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

int main() {
  string s;
  cin >> s;
  int a, z;
  int size = s.size();
  for(int i = 0; i < size; i++){
    if(s.at(i) == 'A'){
      a = i;
      break;
    }
  }
  
  for(int i = size-1; i >= 0;i--){
    if(s.at(i) == 'Z'){
      z = i;
      break;
    }
  }
  cout << z - a + 1 <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int a[110];
int main(){
    int n;
    read(n);
    int sum=0;
    for(i,1,n) read(a[i]),sum+=a[i];
    if(sum%n==0){
        int k=sum/n;
        int ans=0;
        for(i,1,n) ans+=(a[i]-k)*(a[i]-k);
        print(ans),puts("");
    }
    else{
        int k=sum/n;
        int ans=0;
        for(i,1,n) ans+=(a[i]-k)*(a[i]-k);
        int ans1=0; k++;
        for(i,1,n) ans1+=(a[i]-k)*(a[i]-k);
        print(min(ans,ans1)),puts("");
    }
    exit(0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char b;
	cin >> b;
	if (b == 'A')
	{
		cout << 'T' << endl;
	}
	if (b == 'T')
	{
		cout << 'A' << endl;
	}
	if (b == 'G')
	{
		cout << 'C' << endl;
	}
	if (b == 'C')
	{
		cout << 'G' << endl;
	}
	return 0;
}

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

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(a>x)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        if(x-a<=b)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <queue>
//#include <tuple>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

int dx[] ={-1, 0, 0, 1};
int dy[] ={0, -1, 1, 0};

int main(void){
	int a, b; cin >> a >> b;
	if((a+b) % 2 == 1) cout << "IMPOSSIBLE" << endl;
	else cout << (a+b) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define maxd 1000000007
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,black[200200],white[200200];
char s[200200];

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

int main()
{
	n=read();scanf("%s",s+1);
	rep(i,1,n) 
	{
		black[i]=black[i-1]+(s[i]=='#');
		white[i]=white[i-1]+(s[i]=='.');
	}
	int ans=0;
	int bl=black[n],wh=white[n];
	rep(i,0,n)
	{
		//ans=max(black[i]+wh-white[i],ans);
		ans=max(white[i]+bl-black[i],ans);
	}
	ans=n-ans;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>

std::string s, t;

int main(void){
    std::cin >> s >> t;
    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), std::greater<char>());
    puts(s < t ? "Yes" : "No");
    return 0;
}

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

long long MOD = 998244353;
int main()
{
    long long n, x, m; cin >> n >> x >> m;
    long long ans = 0;
    vector<long long> remain; int cnt = 0;
    vector<int> used(m+1); used[m] = 1;
    remain.push_back(x); cnt++;
    long long cur = (x*x) % m; long long sum = x;
    while (used[cur] == 0 && cnt < n)
    {
        if (cur == 0)
        {
            cout << sum << '\n'; return 0;
        }
        sum += cur; remain.push_back(cur); cnt++;
        used[cur] = cnt;
        cur = (cur*cur) % m;
    }
    ans += sum; sum = 0; n -= cnt;
    for (int i = used[cur] - 1; i < cnt; i++)
    {
        sum += remain[i];
    }
    int num = cnt - used[cur] + 1;
    ans += sum * (n / num);
    for (int i = used[cur] - 1; i < used[cur] - 1 + (n % num); i++)
    {
        ans += remain[i];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    vector<int> H(N);
    int m = 0;
    int ans = 1;
    cin >> H[0];
    m = H[0];
    for (int i = 1; i < N; i++)
    {
        cin >> H[i];
        if(m <=H[i]){
            ans++;
            m = H[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
n = gets.chomp.to_i
ans = []
n.times do |i|
  ai = gets.chomp.to_i
  ans[i] = []
  ai.times do
    x, y = gets.chomp.split.map(&:to_i)
    ans[i] << [x - 1, y == 1]
  end
end

[true, false].repeated_permutation(n) do |comb|
  catch :next_comb do
    n.times do |i|
      next unless comb[i]
      ans[i].each do |an|
        throw :next_comb unless comb[an[0]] == an[1]
      end
    end
    puts comb.count(true)
    exit
  end
end


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int x=sqrt(i);
        int ans=0;
        for(int j=1;j<=x;++j)
        {
            for(int k=1;k<=x;++k)
            {
                for(int l=1;l<=x;++l)
                {
                    int val=j*j+k*k+l*l+j*k+k*l+l*j;
                    if(val>i)
                        break;
                    ans+=val==i;
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3692
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
import math
from collections import Counter


def read():
    S = int(input().strip())
    return S,


def solve(S):
    C = 10**9
    p, q = divmod(S, 10**9)
    if q == 0:
        ans = 0, 0, 0, p, 10**9, 1
    else:
        ans = 0, 0, 10**9-q, p+1, 10**9, 1
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 9312
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <vector>
#include <functional>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;

const int N = 2010;

int n, k, cur;
vector<int> g[N];
bool vis[N];
int dep[N], sub[N];

void dfs(int u) {
  sub[u] = 0;
  vis[u] = true;
  if (dep[u] <= k / 2)
    ++cur;
  for (int v : g[u]) {
    if (vis[v]) continue;
    dep[v] = dep[u] + 1;
    dfs(v);
    sub[u] += sub[v];
  }
  if (k % 2 == 1 && dep[u] == k / 2 + 1)
    ++sub[u];
}

int main() {
//  freopen("test.in", "r", stdin);
//  freopen("test.out", "w", stdout);
  
  scanf("%d%d", &n, &k);
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    dep[i] = 0;
    cur = 0;
    dfs(i);
    int mx = 0;
    if (k & 1)
       for (int v : g[i])
         mx = max(mx, sub[v]);
    ans = max(ans, cur + mx);
  }
  printf("%d\n", n - ans);
  
  return 0;
}



Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String S[] = s.split("");
    int[] c = new int[s.length()];
    for(int i = 0;i < s.length();i++){
      c[i] = 0;
    }
    int count = 0;
    String A = "A";
    String C = "C";
    String G = "G";
    String T = "T";
    for(int i = 0;i < s.length();i++){
      if(S[i].equals(A) || S[i].equals(C) || S[i].equals(G) || S[i].equals(T)){
        count++;
      }
      else{
        c[i] = count;
        count = 0;
      }
      c[i] = count;
    }
    int ans = c[0];
    for(int i = 0;i < s.length();i++){
      if(ans < c[i]){
        ans = c[i];
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
/*input
2 1 1 0 0 0 0
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}



int main()
{
	//IOS;
	ll i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll ans=o;
	if((j+l)%2){
		if(i%2&&j>0&&l>0){
			ans+=3;
			i--;j--;l--;
		}
		ans+=i/2*2+j/2*2+l/2*2;
	}
	else{
		if(j%2&&i>0){
			i--;j--;l--;
			ans+=3;
		}
		ans+=i/2*2+j/2*2+l/2*2;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int y = sc.nextInt();
			int x = sc.nextInt();
			if(x == 0 && y == 0)break;
			for ( int i = 0; i < y; i++ ){
				for ( int j = 0; j < x; j++ ){
		        	System.out.print("#");		       
		    	}
		    System.out.println("");		       
			}
		System.out.println("");
		}
	}
}



Measured memory_bytes: 35516
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}

int main(){
	string S;cin>>S;
	puts((S[2]==S[3]&&S[4]==S[5])?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val n         = readInt()
  val Seq(d, x) = readLine().split(" ").map(_.toInt).toSeq
  val a         = (1 to n).map(_ => readInt())
  println(a.map(i => (0 until d).count(_ * i + 1 <= d)).sum + x)
}


Measured memory_bytes: 54964
#include<stdio.h>

int main(){
  int i,j,k;
  int N,M;
  
  scanf("%d %d",&N,&M);
  
  int A[2*M];
  
  for(i=0;i<2*M;i+=2)
    scanf("%d %d",&A[i],&A[i+1]);
  
  int B[N+1];
  for(i=1;i<=N;i++)
    B[i]=0;
  
  for(i=0;i<2*M;i++){
    B[A[i]]++;
  }
  
  for(i=1;i<=N;i++){
    printf("%d\n",B[i]);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
    
    int a, b, c;
    
    cin >> a >> b >> c;
    
    int tmp = max(a, b);
    int m = max(c, tmp);
    
    int remain = m - a;
    remain += (m - b);
    remain += (m - c);
    
    if (remain % 2 == 0)
    {
        cout << remain / 2 << endl;
    }
    else
    {
        cout << (remain / 2) + 2 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//Different Strokes

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<int>s(n);
    int a=0;
    rep(i,0,n){
        int q,w;
        cin>>q>>w;
        a-=w;
        s[i]=q+w;
    }
    sort(range(s),greater<int>());
    rep(i,0,n){
        if(i%2==0)a+=s[i];
    }
    cout<<a<<nnn;
    return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

typedef long long int lli;

typedef pair<lli, lli> pii;
typedef vector<lli> vi;
typedef set<lli> si;
typedef unordered_map<lli, lli> umii;
typedef unordered_set<lli> usi;

lli mod = 1000000007;

void dispvec(si arr)
{
    si::iterator itr = arr.begin();
    while (itr != arr.end())
    {
        cout << *itr << " ";
        itr++;
    }
    cout << endl;
}

struct CustomCompare
{
    //stable sort by first then second both in increasing
    bool operator()(const pii &i, const pii &j)
    {
        if (i.first == j.first)
            return i.first < j.first;
        return i.second < j.second;
    }
};

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

void solve()
{
    int n, k;
    cin >> n >> k;
    vi arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vi dp(n, 0);
    if (n == 2)
    {
        cout << abs(arr[0] - arr[1]);
        return;
    }
    lli mini = 1000000001;
    int i = 0;
    dp[1] = abs(arr[0] - arr[1]);
    for (i = 2; i <= k && i < n; i++)
    {
        mini = 1000000001;
        for (int j = i - 1; j >= 0; j--)
        {
            mini = min(mini, dp[j] + abs(arr[j] - arr[i]));
        }
        dp[i] = mini;
    }
    for (; i < n; i++)
    {
        mini = 1000000001;
        for (int j = i - 1; j >= i - k; j--)
        {
            mini = min(mini, dp[j] + abs(arr[j] - arr[i]));
        }
        dp[i] = mini;
    }
    cout << dp[n - 1] << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/input", "r", stdin);
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/output", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    int i = 1;
    while (i <= t)
    {
        solve();
        i++;
    }

    return 0;
}

Measured memory_bytes: 4772
a,b,c,x,y=map(int, input().split())
okn=0
if(a+b>c*2):
    xy=abs(x-y)
    m=max(x,y)
    z=m-xy
    if(m==x):
        if(a>c*2):
            okn=c*2*x
        else:
            okn+=c*2*z
            okn+=a*xy
    else:
        if(b>c*2):
            okn=c*2*y
        else:
            okn+=c*2*z
            okn+=b*xy
else:
    okn+=a*x+b*y
print(okn)


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<string.h>

using namespace std;

int maxx(int n, int*d) {
	int max = 0;
	max = d[0];
	for (int i = 1; i < n; i++) {
		if (max < d[i]) {
			max = d[i];
		}
	}

	return max;
}
int main() {

	int n;
	cin >> n;

	char s[128];
	cin >> s;
	int count[128] = {};

	/*char *xx = s;
	char *yy = &s[2];*/

	int max = 0;

	for (int i = 1; i < n; i++) {
		char *x = s;
		
		int bag[26] = {};
		
		for (int j = 0; j < i; j++) {
			bag[x[j]-'a']=1;	
		}
		for (int j = i; j < n; j++) {
			if (bag[x[j]-'a'] == 1)bag[x[j]-'a'] = 2;
			//bag[x[j] -'a']++;
		}

		for (int j = 0; j < 26; j++) {
			if (bag[j] > 1)count[i]++;
		}
		if (max < count[i])max = count[i];
	}
	//int max = 0;
	
	//max = maxx(n,count);

	printf("%d", max);
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    for (int i = 0; i < v.size(); i++) {
        if (i) os << ", ";
        os << v[i];
    }
    os << "}";
    return os;
}

int main()
{
    ll mod = 998244353;
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    vector<int> r(n);
    for (int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }

    vector<ll> dp(n, 0);
    vector<ll> acc(n+1, 0);
    dp[0] = 1;
    acc[1] = 1;

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < k; j++) {
            dp[i] += acc[max(0, i - l[j] + 1)] - acc[max(0, i - r[j])];
            dp[i] = (dp[i] + mod) % mod;
            acc[i+1] = acc[i] + dp[i];
            acc[i+1] %= mod;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 8016
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
    if(a.first.first!=b.first.first) {
        return a.first.first < b.first.first;
    } else {
        return a.first.second > b.first.second;
    }
}

int main() {
    int n;
    cin >> n;
    
    vector<pair<pair<string, int>, int> > lst(n, pair<pair<string, int>, int>());
    for(int i=0; i<n; i++) {
        string s;
        int p;
        
        cin >> s >> p;
        
         lst[i] = make_pair(make_pair(s, p), i+1);
    }
    
    sort(lst.begin(), lst.end(), cmp);

    for(int i=0; i<n; i++) {
        cout << lst[i].second << endl;
    }

    return 0;
    
}

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

using namespace std;

// Thursday 3/19/20

//  

//  

// 158 A Station and bus

int main() {
	string value;
	cin >> value;
	if (value == "AAA" || value == "BBB") {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}



Measured memory_bytes: 256
l = raw_input().split()
price1 = int(l[0]) + int(l[1])
price2 = int(l[0]) + int(l[2])
price3 = int(l[1]) + int(l[2])
if price1 > price2:
	price = price2
else:
	price = price1
if price > price3:
	price = price3
print price

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; long K; cin>>N>>K;
	int A[64][N];
	rep(i,0,N){ cin>>A[0][i]; A[0][i]--; }
	rep(i,0,63){
		rep(j,0,N) A[i+1][j] = A[i][A[i][j]];
	}
	int t = 0;
	rep(i,0,64){
		if(K & (1l<<i)){
			t = A[i][t];
		}
	}
	cout<<t + 1<<endl;
}

Measured memory_bytes: 53620
#include <iostream>

using namespace std;


int main()
{
	int S, M;
	int h, m, s;

	cin >> S;

	s = S % 60;
	M = (S - s) / 60;
	m = M % 60;
	h = (M - m) / 60;

	cout << h << ":" << m << ":" << s << endl;


    return 0;
}




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

int main(){
 long int a,b,N;
  scanf("%ld %ld %ld",&N,&a,&b);
long int e;
  if((N%(a+b))-a>0){
  e=a*(N/(a+b))+a;
  }else{
    e=a*(N/(a+b))+(N%(a+b));
  }
  printf("%ld",e);
}
  

Measured memory_bytes: 128
import Control.Applicative ((<$>))
import Control.Monad (replicateM_, forM_, unless, when)
import Data.Vector.Mutable (IOVector)
import qualified Data.Vector.Mutable as VM

main :: IO ()
main = do
  m <- readLn
  unless (m == 0) $ do
    tbl <- VM.replicate (mxi+1) 0 :: IO (IOVector Int)
    VM.write tbl 0 1
    replicateM_ m $ do
      [a, b] <- map read <$> words <$> getLine
      forM_ [mxi, mxi-1 .. 0] $ \i -> do
        x <- VM.read tbl i
        when (x > 0) $ do
          forM_ [a, 2*a .. a*b] $ \j -> do
            modify tbl (+ x) (i + j)
    g <- readLn
    replicateM_ g $ do
      n <- readLn
      VM.read tbl n >>= print
    main

mxi :: Int
mxi = 8000

modify :: IOVector Int -> (Int -> Int) -> Int -> IO ()
modify v f i = do
  x <- VM.read v i
  VM.write v i (f x)



Measured memory_bytes: 5648
<?php
while ($input = trim(fgets(STDIN))) {
	list($n, $x) = explode(" ", $input);
	if (!$n) break;
	$result = 0;
	for ($i = 1; $i <= $n-2; $i++) {
		for ($j = $i+1; $j <= $n-1; $j++) {
			for ($k = $j+1; $k <= $n; $k++) {
				if ($i+$j+$k == $x) $result++;
			}
		}
	}
	echo $result."\n";
}

Measured memory_bytes: 15292
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int tt,ans;
int f[N],head[N],to[N*2],nxt[N*2];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void dfs(int x,int fa) {
    int s=0,t=0;
    for(int i=head[x];i;i=nxt[i]) {
	int y=to[i];
	if(y!=fa) {
	    dfs(y,x);
	    s|=f[x]&f[y],f[x]|=f[y];
	}
    }
    while((1<<t)<=s||f[x]>>t&1) ++t;
    ans=max(ans,t),f[x]=((f[x]>>t)|1)<<t;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<n;i++) {
	int x=gi(),y=gi();
	to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
	to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
    }
    dfs(1,0);
    cout<<ans;
    return 0;
}

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

int main() {
	char S[1000000 * 2 + 1] = {};
	int N, ans = 0,count;
	bool flag = false;
	cin >> N >> S;
	for (int i = 0; i < N; i++)
	{
		if (!flag&&S[i] == '#')
		{
			flag = true;
		}
		if (S[i] == '#')
		{
			count++;
		}
		if (flag&&S[i] == '.')
		{
			ans++;
		}
		ans = min(ans, count);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << 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 debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	cin >> n;
 	vector <ll> vec(n);
 	for (ll i = 0; i < n; i++) cin >> vec[i];
 	ll ans = 0;
 	for (ll i = 1; i < n; i++) {
 		if (vec[i] < vec[i - 1]) {
 			ans += vec[i - 1] - vec[i];
 			vec[i] = vec[i - 1];
 		}
 	}
 	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4752
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int A[200010];
int L[200010];
int R[200010];

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

	int N;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
		if (i > 0)
		{
			A[i] += A[i - 1];
		}
	}

	int li = 0, ri = N - 2;
	L[1] = li, R[N - 3] = ri;
	rep(i, 2, N)
	{
		while (li + 1 < i&&abs(A[i] - A[li] - A[li]) > abs(A[i] - A[li + 1] - A[li + 1]))
		{
			li++;
		}
		L[i] = li;
	}
	rrep(i, 0, N-3)
	{
		while (i<ri - 1 && abs(A[N - 1] - A[ri] - A[ri] + A[i]) > abs(A[N - 1] - A[ri - 1] - A[ri - 1] + A[i]))
		{
			ri--;
		}
		R[i] = ri;
	}

	int ans = INF;
	int maxv, minv;
	rep(i, 1, N - 2)
	{
		maxv = max(A[N - 1] - A[R[i]], max(A[R[i]] - A[i], max(A[i] - A[L[i]], A[L[i]])));
		minv = min(A[N - 1] - A[R[i]], min(A[R[i]] - A[i], min(A[i] - A[L[i]], A[L[i]])));
		chmin(ans, maxv - minv);
	}

	cout << ans << endl;

	return 0;
}

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


namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        static void Main()
        {

            switch (int.Parse(Console.ReadLine()) % 10)
            {

                case 0:
                case 1:
                case 6:
                case 8:

                    Console.WriteLine("pon");
                    break;

                case 2:
                case 4:
                case 5:
                case 7:
                case 9:

                    Console.WriteLine("hon");
                    break;

                case 3:

                    Console.WriteLine("bon");
                    break;

            }

        }
    }
}


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

using namespace std;

int main(){
    long long N, A[200000], array[200000];
    cin >> N;
    long long median = 0, sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A+N);
    median = (N&1 ? A[N/2] : (A[N/2-1]+A[N/2])/2);
    for (int i = 0; i < N; ++i) {
        sum += abs(A[i] - median);
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 1792
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x: i64,
    }
    for a in -200..=200 {
        for b in -200..=200 {
            if a*a*a*a*a - b*b*b*b*b == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


Measured memory_bytes: 2176
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

keta = [0,0,0]
DP = [0,0,0]

for i in sc:
  s = i[0]
  c = i[1]
  if DP[-1*N+s-1] == 0 or (DP[-1*N+s-1] == 1 and keta[-1*N+s-1] == c):
    keta[-1*N+s-1] = c
    DP[-1*N+s-1] = 1
  else:
    DP[-1*N+s-1] = -1
    
if keta[-1*N] == 0:
  if DP[-1*N] == 1 and N != 1:
    DP[-1*N] = -1
  elif N != 1:
    keta[-1*N] = 1
    DP[-1*N] = 1
  else:
    DP[-1*N] = 1
  
if -1 in DP:
  print(-1)
else:
  ans = ''
  for i in keta:
    ans += str(i)
  print(int(ans[3-N:]))
#print(DP)

Measured memory_bytes: 9060
sa = raw_input()
sb = raw_input()
sc = raw_input()

ia = ib = ic = 0
turn = 'a'
while(True):
    if turn == 'a':
        if ia == len(sa):
            print 'A'
            break
        turn = sa[ia]
        ia += 1
    elif turn == 'b':
        if ib == len(sb):
            print 'B'
            break
        turn = sb[ib]
        ib += 1
    else:
        if ic == len(sc):
            print 'C'
            break
        turn = sc[ic]
        ic += 1


Measured memory_bytes: 2568
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;


int main(){
    int a, b;
    cin>>a>>b;
    string str1, str2;
    for(int i = 0; i< a; i++){
        str1+=(b+'0');
    }
    for(int i = 0; i< b; i++){
        str2+=(a+'0');
    }
    if(str1<str2)cout<<str1;
    else cout<<str2;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [n, y] <- map read . words <$> getLine
  putStr . unwords . map show $ solve n y

solve :: Int -> Int -> [Int]
solve n y = modify n y $ optimize y

optimize :: Int -> [Int]
optimize y = [a, b, c]
  where
    (a, r) = y `divMod` 10000
    (b, q) = r `divMod` 5000 
    c = q `div` 1000

modify :: Int -> Int -> [Int] -> [Int]
modify n y [a, b, c]
  | n == s = [a, b, c]
  | n - s >= 4 && b > 0 = modify n y [a, b - 1, c + 5]
  | n - s >= 0 && a > 0 = modify n y [a - 1, b + 2, c]
  | otherwise = [-1, -1, -1]
  where
    s = sum [a, b, c]




Measured memory_bytes: 508
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr[0]=arr[0]%m
for i in range(1,n):
  arr[i]=(arr[i]+arr[i-1])%m
dic={}
for i in arr:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1
ans=0
for i in dic.keys():
  if i==0:
    ans+=dic[i]
  ans+=(dic[i]*(dic[i]-1))//2
print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int x[5];
    rep(i, 5)   cin >> x[i];
    rep(i, 5){
        if(!x[i]){
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long int n;
	cin>>n;
	unsigned long long int ans=0;
	if(n%2==1)
	{
		cout<<0;
		return 0;
	}
	n=n/2;
	while(n>0)
	{
		ans+=n/5;
		n=n/5;
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

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

    string ans = "S";
    ans+='S';
    for(int i=1;i<N;i++){
        if(S[i]=='o'){
            if(ans[i]=='S') ans += ans[i-1];
            else ans += (ans[i-1]=='S'?'W':'S');
        }
        else{
            if(ans[i]=='S') ans += (ans[i-1]=='S'?'W':'S');
            else ans += ans[i-1];
        }
    }
    if((ans[0]==ans[N]) && ((S[0]=='o' && ans[1]==ans[N-1]) || (S[0]=='x' && ans[1]!=ans[N-1]))){
        cout << ans.substr(0,N) << endl;
        return 0;
    }

    ans = "S";
    ans+='W';
    for(int i=1;i<N;i++){
        if(S[i]=='o'){
            if(ans[i]=='S') ans += ans[i-1];
            else ans += (ans[i-1]=='S'?'W':'S');
        }
        else{
            if(ans[i]=='S') ans += (ans[i-1]=='S'?'W':'S');
            else ans += ans[i-1];
        }
    }
    if((ans[0]==ans[N]) && ((S[0]=='o' && ans[1]==ans[N-1]) || (S[0]=='x' && ans[1]!=ans[N-1]))){
        cout << ans.substr(0,N) << endl;
        return 0;
    }
    
    ans = "W";
    ans += 'S';
    for(int i=1;i<N;i++){
        if(S[i]=='o'){
            if(ans[i]=='S') ans += ans[i-1];
            else ans += (ans[i-1]=='S'?'W':'S');
        }
        else{
            if(ans[i]=='S') ans += (ans[i-1]=='S'?'W':'S');
            else ans += ans[i-1];
        }
    }
    if((ans[0]==ans[N]) && ((S[0]=='x' && ans[1]==ans[N-1]) || (S[0]=='o' && ans[1]!=ans[N-1]))){
        cout << ans.substr(0,N) << endl;
        return 0;
    }

    ans = "W";
    ans += 'W';
    for(int i=1;i<N;i++){
        if(S[i]=='o'){
            if(ans[i]=='S') ans += ans[i-1];
            else ans += (ans[i-1]=='S'?'W':'S');
        }
        else{
            if(ans[i]=='S') ans += (ans[i-1]=='S'?'W':'S');
            else ans += ans[i-1];
        }
    }
    if((ans[0]==ans[N]) && ((S[0]=='x' && ans[1]==ans[N-1]) || (S[0]=='o' && ans[1]!=ans[N-1]))){
        cout << ans.substr(0,N) << endl;
        return 0;
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
def main():
    N, Y = [int(x) for x in input().strip().split()]
    
    for ni in range(N+1)[::-1]:
        sum = ni * 10000
        if sum > Y:
            continue

        M = N - ni

        if M == 0:
            if sum == Y:
                return "{} {} {}".format(ni, 0, 0)
            continue

        for mi in range(M+1)[::-1]:
            sum = (ni*10000) + (mi*5000) + ((N-ni-mi) * 1000)
            if sum == Y:
                return "{} {} {}".format(ni, mi, N-ni-mi)
    return "-1 -1 -1"
    
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  double A, B;
  cin >> A >> B;
  double Amin, Amax, Bmin, Bmax;
  Amin = ceil(A * 100 / 8);
  Amax = ceil((A + 1) * 100 / 8) - 1;
  Bmin = ceil(B * 10);
  Bmax = ceil((B + 1) * 10) - 1;
  if (Amax < Bmin || Bmax < Amin) {
    cout << -1 << endl;
  } else {
    cout << max(Amin, Bmin) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[6] == '5' || s[6] == '6' || s[6] == '7' || s[6] == '8' || s[6] == '9' || s[5] == '1'&&s[6] == '0' || s[5] == '1'&&s[6] == '1' || s[5] == '1'&&s[6] == '2') cout << "TBD" << endl;
	else cout << "Heisei" << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char c[MAXN];

void solve(){
	int n, k;
	scanf("%s%d", &c[0], &k);
	n = strlen(c);
	REP(i, 0, n){
		if (c[i] != 'a'){
			int d = 26 - (c[i] - 'a');
			if (d <= k){
				c[i] = 'a';
				k -= d;
			}
		}
	}
	k %= 26;
	while(k--){
		c[n - 1]++;
		if (c[n - 1] > 'z'){
			c[n - 1] = 'a';
		}
	}
	printf("%s\n", c);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 384
#include<stdio.h>

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

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);

        int w = inp.nextInt();
        int h = inp.nextInt();
        int x = inp.nextInt();
        int y = inp.nextInt();
        int r = inp.nextInt();

        if (x+r <= w && x-r >= 0) {
            if (y+r <= h && y-r >= 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26252
n = gets.to_i
as = n.times.map { gets.to_i }

keys = as.uniq.sort
max = as.max

counts = Hash.new(0)
as.each do |a|
  counts[a] += 1
end

as.each do |a|
  if a == max && counts[max] < 2
    puts keys[-2]
  else
    puts max
  end
end


Measured memory_bytes: 13460
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;
  	double tmp;
    cin >> n;
    vector<double> vec(n);
    rep(i,n)cin >> vec.at(i);
    sort(vec.begin(),vec.end());
    tmp=vec.at(0);
    rep(i,n-1){
        tmp+=vec.at(i+1);
        tmp/=2.0;
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int ans;
 
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    while (x % 2 == 0) {
      ans++;
      x /= 2;
    }
  }
  printf("%d\n", ans);
  return 0;     
}

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

int main(){
  int n, num[4][222];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> num[0][i] >> num[1][i] >> num[2][i];
  }
  for(int i = 0;i < n;i++){
    int res = 0;
    for(int j = 0;j < 3;j++){
      res += num[j][i];
      for(int k = 0;k < n;k++){
	if(i == k)continue;
	if(num[j][i] == num[j][k]){
	  res -= num[j][i];
	  break;
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n,m=map(int,input().split())
list1=[]
for i in range(n):
  l=list(map(int,input().split()))
  del l[0]
  list1.append(l)
c=0
for i in range(1,1+m):
  b=True
  for j in range(n):
    if i in list1[j]:
      pass
    else:
      b=False
  if b==True:
    c+=1
print(c)

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

int main()
{
  string a,l,r;
  cin >> a;
  int len;
  while(1){
    a.pop_back();
    a.pop_back();
    len = a.size();
    l = a.substr(0,len/2);
    r = a.substr(len/2,len/2);
    if(l == r) break;
  }
  cout << len << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<double> sum(n+1,0);
    for(int i=1;i<=n;i++){
        int p;
        cin>>p;
        sum[i]=((1+p)/2.0)+sum[i-1];
    }
    double ans=0;
    for(int i=0;i+k<=n;i++){
        ans=max(ans,sum[k+i]-sum[i]);
    }
    printf("%.6lf\n",ans);
    return 0;
}


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

using namespace std;

long long n, m;

int main()
{
	scanf("%lld%lld", &n, &m);
	if (n == 1 && m == 1) printf("1\n");
	else if (n == 1) printf("%lld\n", m - 2);
	else if (m == 1) printf("%lld\n", n - 2);
	else printf("%lld\n", (n - 2LL) * (m - 2LL));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
//typedef long long int lli;

int main() {
  long n, k;
  cin >> n >> k;
  
  if( n % k == 0)
    cout << 0 << endl;
  else{
    long d =fabs((n % k) - k);
    if( d < n)
      cout << d << endl;
    else
      cout << n << endl;
  }
  
}


Measured memory_bytes: 256
N = int(input())
input = input().split()

marker = True
count = 0
num = 0

while(marker):
    for i in range(N):
        num = int(input[i])
        if num%2==1:
            marker = False
            count -= 1
            break;
        else:  
            input[i] = num/2 
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	// 標準入力からデータを読み込む準備
	try (Scanner sc = new Scanner(System.in)) {

		String line = sc.nextLine();
		String answer = "";
		int length = line.length();
		for (int i = 0; i < length; i++) {
 			// 文字列(line)からi番目の文字を取り出す
			char ch = line.charAt(i);
			// Character.isLowerCase で小文字かどうか判断可能
			if(Character.isLowerCase(ch))
			{
				answer += Character.toUpperCase(ch);
			}
			else
			{
				answer += Character.toLowerCase(ch);
			}
			// Character.toUpperCase, Character.toLowerCase で変換
			// 記号は上記メソッドで変換にかけても変化しない
		}
		System.out.println(answer);
	}
	}
}


Measured memory_bytes: 31316
from collections import deque
H,W = map(int,input().split())
S= [[0]* W for _ in range(H)]
for i in range(H):
  S[i] = list("".join(input()))

def BFS(i,j):
  v= deque([[i,j]])
  d= [[-1 for _ in range (W)] for _ in range(H)]
  d[i][j]=0
  
  while len(v)>0:
    a=v.popleft()
    s=a[0]
    t=a[1]
    if s>0:
      if d[s-1][t]==-1 and S[s-1][t]==".":
        d[s-1][t]= d[s][t]+1
        v.append([s-1,t])
    if s<H-1:
      if d[s+1][t]==-1 and S[s+1][t]==".":
        d[s+1][t]= d[s][t]+1
        v.append([s+1,t])
    if t>0:
      if d[s][t-1]==-1 and S[s][t-1]==".":
        d[s][t-1]= d[s][t]+1
        v.append([s,t-1])
    if t<W-1:
      if d[s][t+1]==-1 and S[s][t+1]==".":
        d[s][t+1]= d[s][t]+1
        v.append([s,t+1])
  maxi=0
  for i in range(H):
    for j in range(W):
      maxi=max(maxi,d[i][j])
  #print(d)
  return maxi

ans=0
for i in range(0,H):
  for j in range(0,W):
    if S[i][j]==".":
      ans=max(ans,BFS(i,j))
print(ans)
#BFS(H-1,W-1)

Measured memory_bytes: 58992
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int cnt=0;
  string S,T;
  cin>>S>>T;
  if(S[0]==T[0]) cnt++;
  if(S[1]==T[1]) cnt++;
  if(S[2]==T[2]) cnt++;
  cout<<cnt;
}

Measured memory_bytes: 256