akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  ll a,b;
  cin>>a>>b;
  ll h[N];

  rep(i,N){
    cin>>h[i];
  }



  int ng = -1; // 最初のindexより1つ前 ngとokは場合により入れ替え
  int ok = 1000000000; // 最後のindexより1つあと
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    bool noo=false;

    ll ct=0;
    rep(i,N){
      ct+=max((ll)0,((h[i]-b*mid)+(a-b-1))/(a-b));
    }
    if(ct>mid) ng=mid;
    else ok=mid;

  }

  cout<< ok<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main() {
  int n, k = 0;
  cin >> n;

  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  y = x;
  sort(y.begin(), y.end());
  reverse(y.begin(), y.end());

  for (int i = 0; i < n; i++) {
    if (x[i] < y[n / 2 - 1])
      cout << y[n / 2 - 1] << endl;
    else
      cout << y[n / 2] << endl;
  }
}


Measured memory_bytes: 3712
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 or b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  #define int long long
  int X,Y,A,B,C;
  int rs;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A);
  vector<int> q(B);
  vector<int> r(C);
  
  for(int i=0;i<A;i++){
    cin >> p[i];
  }
  for(int i=0;i<B;i++){
    cin >> q[i];
  }
  for(int i=0;i<C;i++){
    cin >> r[i];
  }
  std::sort(p.begin(), p.end(), std::greater<int>() );
  std::sort(q.begin(), q.end(), std::greater<int>() );
  for(int i=0; i<X; i++){
    r.push_back(p[i]);
  }
  for(int i=0; i<Y; i++){
    r.push_back(q[i]);
  }
  std::sort(r.begin(), r.end(), std::greater<int>() );
  rs = 0;
  for(int i=0; i<(X+Y); i++){
    rs += r[i];
  }
  cout << rs << endl;
}



Measured memory_bytes: 6384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b+c<=21){
        printf("win");
        return 0;
    }
    printf("bust");
    return 0;
}

Measured memory_bytes: 1696
#include<iostream>
using namespace std;
int main(){
 	int n,x,t;
  	cin>>n>>x>>t;
  	int r = n%x;
  	if(r==0){
      cout<<(n/x)*t<<endl;
    }else if(x<n){
      cout<<(n/x)*t + t <<endl;
    }else{
      cout<<t<<endl;
    }
	return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
#Tenka1 Programmer Contest

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

N = I()
for h in range(1,3500+1):
    for n in range(1,3500+1):
        if 4*h*n - h*N - n*N <= 0:
            continue
        w = (n*h*N)/(4*h*n - h*N - n*N)
        if w % 1 == 0:
            print(h,n,int(w))
            quit()


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

int main(int argc, char *argv[])
{
    int n;
    std::vector<long long> a;
    std::vector<long long> x;

    std::cin >> n;

    a.resize(n);
    x.resize(n);

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

    long long x0 = a[0];
    for (int i = 1; i < n; i++) {
        x0 += ((i % 2)?(-1LL):(+1LL)) * a[i]; 
    }

    x[0] = x0;
    for (int i = 1; i < n; i++) {
        x[i] = 2LL * a[i - 1] - x[i - 1]; 
    }

    for (int i = 0; i < n; i++) {
        std::cout << x[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 2944
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int t,i,j,n,c[1024],s[1024],f[1024],r=0;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    }
    for(i=1;i<=n;i++){
        t=0;
        for(j=i;j<n;j++){
            t=max(s[j],f[j]*ceil(t,f[j]))+c[j];
        }
        printf("%d\n",t);
    }
    //printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

        Queue<String> queue = new LinkedList<>();
        queue.add(String.valueOf(S.charAt(0)));
        for (int i = 1; i < S.length(); i++) {
            String ch = String.valueOf(S.charAt(i));

            List<String> list = new ArrayList<>();
            while(!queue.isEmpty()){
                String val = queue.remove();
                list.add(val + ch);
                list.add(val + "+" + ch);
            }
            queue.addAll(list);
        }

        Long ans = 0L;
        while(!queue.isEmpty()) {
            String formula = queue.remove();
            String[] splits = formula.split("\\+");
            for (String split : splits) {
                ans += Long.valueOf(split);
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
import sys
input = sys.stdin.readline

X = int(input())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

void printMap(map<ll, ll> m) {
    for (auto x : m) {
        cout << x.first << ' ' << x.second << '\n';
    }
    cout << '\n';
}

int main() {

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n, m;
    cin >> n >> m;
    map<ll, ll> mapa;
    for (int i = 1; i <= n; i++) {
        //cout << i << '\n';
        ll a, b;
        cin >> a >> b;
        mapa[a] += b;
    }
    ll needed = m;
    ll tot = 0;
    //printMap(mapa);
    for (auto x : mapa) {
        if (x.second < needed) {
            tot += x.first * x.second;
            needed -= x.second;
            //cout << needed << '\n';
        }
        else {
            tot += x.first * needed;
            needed = 0;
            break;
        }
    }
    //cout << needed << '\n';
    cout << tot << '\n';
    return 0;
}

Measured memory_bytes: 9912
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	vi a(9);
	rep(i, 9) cin >> a[i];
	int n; cin >> n;
	rep(i, n){
		int x; cin >> x;
		rep(j, 9) if(a[j] == x) a[j] = -1;
	}
	bool ans = 0;
	{
		bool ok = 1;
		rep(i, 3) if(a[i * 3 + i] >= 0) ok = 0;
		ans |= ok;
	}
	{
		bool ok = 1;
		rep(i, 3) if(a[i * 3 + 2 - i] >= 0) ok = 0;
		ans |= ok;
	}
	rep(i, 3){
		bool ok = 1;
		rep(j, 3) if(a[i * 3 + j] >= 0) ok = 0;
		ans |= ok;
	}
	rep(j, 3){
		bool ok = 1;
		rep(i, 3) if(a[i * 3 + j] >= 0) ok = 0;
		ans |= ok;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

pair<int, int> a[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a, a + n, [](pair<int, int> x, pair<int, int> y) {
    return x.first < y.first;
  });
  for (int i = 0; i < n; i++) {
    cout << a[i].second << " ";
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n); 
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	vector<bool> dp(k+1, 0);
	for(int i=1; i<=k; i++) {
		for(int j=0; j<n; j++) {
			if (i - v[j] >= 0 and dp[i-v[j]] == 0) dp[i] = 1; 
		}
	}

	if (dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
}



Measured memory_bytes: 760
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

type Price = Integer
type NumOfPizza = Integer

halfAndHalf :: Price -> Price -> Price -> NumOfPizza -> NumOfPizza -> Price
halfAndHalf a b c x y
            | abLT2c = a * x + b * y
            | x > y = min (costOf2Y + costOfrestA) costOf2X
            | otherwise = min (costOf2X + costOfrestB) costOf2Y
            where
                abLT2c = if a + b < 2 * c then True else False
                costOf2Y = y * 2 * c
                costOfrestA = (x - y) * a
                costOf2X = (x * 2 * c)
                costOfrestB = (y - x) * b

main = do
     [a,b,c,x,y] <- getIntList
     print $ halfAndHalf a b c x y

Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c && c<=b){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, k; cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> b(n);
    for (int i = 0; i < n - 1; i++) b[i] = a[i + 1] - a[i];
    b[n - 1] = k + a[0] - a[n - 1];
    sort(b.begin(), b.end());
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) ans += b[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,q; cin>>n>>q;
    long long a[n]; rep(i,n) cin>>a[i];
    while(q--){
        long long x; cin>>x;
        long long r=0,sum=0,ans=0;
        for(int l=0;l<n;l++){
            while(r<n&&sum+a[r]<=x){
                sum+=a[r];
                r++;
            }
            ans+=r-l;
            if(l==r) r++;
            else sum-=a[l];
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3864
N = int(input())
numbers = list(map(int, input().split()))
 
sums = [0] * (N + 1)
for i in range(len(numbers)):
  sums[i] = sums[i-1]+numbers[i]
sums = sorted(sums)

temp = ""
count = 0
res = 0
for i in range(len(sums)):
  if temp == sums[i]:
    count += 1
  else:
    if count >= 2:
      c = 1
      for j in range(count-1, count+1):
        c *= j
      res += c/2
    count = 1
    temp = sums[i]
    
if count >= 2:
  c = 1
  for i in range(count-1, count+1):
    c *= i
  res += c/2
    
print(int(res))

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

public class Main{
	public static void main(String[] args){
		ArrayList<Integer> A = new ArrayList<Integer>();
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		for(int i=0;i<N;i++){
			A.add(scanner.nextInt());
		}
		printList(A,N);
		insertionSort(A,N);
	}
	
	static void insertionSort(ArrayList<Integer> A,int N){
		for(int i=1;i<N;i++){
			int v = A.get(i);
			int j=i-1;
			while(j>=0 && (v < A.get(j))){
				A.set(j+1,A.get(j));
				j--;
			}
			//??????????±????i????????????v??????j??????????????\??????????????????????????\?????????
			A.set(j+1, v);
			printList(A,N);
		}
	}
	static void printList(ArrayList<Integer> A,int N){
		StringBuilder builder = new StringBuilder();
		for(int i=0;i<N;i++){
			if(i>0){
				builder.append(" ");
			}
			builder.append(A.get(i));
		}
		System.out.println(builder);
	}
}

Measured memory_bytes: 29252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int a[4];
	int b[4];
	while(cin >> a[0]){
		int hit = 0;
		int brow = 0;
		FOR(i,1,4){
			cin >> a[i];
		}
		rep(i,4){
			cin >> b[i];
			if(a[i] == b[i])hit++;
		}
		rep(i,4)rep(j,4){
			if(a[i] == -1 || b[j] == -1)continue;
			if(a[i] == b[j]){
				brow++;
				a[i] = -1; b[j] = -1;
			}
		}
		cout << hit << " " << (brow-hit) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
main = do
  n <- words <$> getLine
  let l = read $ head n
  let op = head $ tail n
  let r = read $ last n
  putStrLn $ biop op l r
  
biop :: String -> Int -> Int -> String
biop o l r
  | o == "+" = show $ l + r
  | o == "-" = show $ subtract r l
  | otherwise = undefined

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  int count_i = 0;
  int num = 0;
  while(count_i<N){
    string hinaarare;
    cin >> hinaarare;

    if(hinaarare == "Y"){
      num += 1;
    }
    count_i++;
  }
  if (num  > 1) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)
    if left > right:
        break
print(max(right - left + 1, 0))


Measured memory_bytes: 27332
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200002;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
#define biton(x, y) (((x>>y)&1ll) == 1)
#define bitoff(x, y) (((x>>y)&1ll) == 0)

int32_t main()
{ 
   IOS

  int x;
  cin >> x;
  for(int i = 400, j = 8;;i+=200, j--){
    if(x>=i and x<=i+199){
      cout << j  << endl;
      return 0;
    }
  } 


 
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a+b>=k)cout << min(k,a) << endl;
  else cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a; string s;
    cin >> a >> s;
    cout << ((a >= 3200) ? s : "red" ) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int s = sc.nextInt();
		int m = s/60; s %= 60;
		int h = m/60; m %= 60;
		System.out.println(h+":"+m+":"+s);
		
	}
}


Measured memory_bytes: 26376
N, A, B, C = map(int, input().split())
L = []
INF = float('inf')
for i in range(N):
    L.append(int(input()))


def dfs(a, b, c, k):
    if k == N:
        if min(a, b, c) > 0:
            return abs((a - A)) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    tmp = INF
    tmp = min(tmp, dfs(a, b, c, k + 1))
    tmp = min(tmp, dfs(a + L[k], b, c, k + 1) + 10)
    tmp = min(tmp, dfs(a, b + L[k], c, k + 1) + 10)
    tmp = min(tmp, dfs(a, b, c + L[k], k + 1) + 10)

    return tmp


print(dfs(0, 0, 0, 0))



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

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

    for (int i = n; i < 1000000; i++) {
        int x = i;
        bool ok = true;
        while (x > 0) {
            rep(j, k) if (x % 10 == d[j]) ok = false;
            x /= 10;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3548
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = Integer.valueOf(sc.next());

        for (int i = 0; i < count; i++) {
            int[] nums = new int[]{
                    Integer.valueOf(sc.next()),
                    Integer.valueOf(sc.next()),
                    Integer.valueOf(sc.next())
            };
            Arrays.sort(nums);
            System.out.println(isRightTriangle(nums) ? "YES" : "NO");
        }
    }

    public static boolean isRightTriangle(int[] nums) {
        return (nums[0] * nums[0]) + (nums[1] * nums[1]) == (nums[2] * nums[2]);
    }
}

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

int main(){
	int x,y;
	cin>>x>>y;
	if (x==1&&y==1) {
		cout<<1<<endl;
		return 0;
	}
	else if (x==1||y==1) {
		cout<<max(x,y)-2<<endl;
		return 0;
	}
	else {
		cout<<(long long)(x-2)*(long long)(y-2)<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
//長方形の中に円が含まれるかを判定するプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iWide;
    int iHight;
    int iCoordX;
    int iCoordY;
    int iRadius;

    //変数の初期化
    iWide = 0;
    iHight = 0;
    iCoordX = 0;
    iCoordY = 0;
    iRadius = 0;
    
    scanf ("%d %d %d %d %d",&iWide, & iHight, &iCoordX, &iCoordY, &iRadius);
    if ((iCoordX >= iRadius) && (iCoordX <= (iWide - iRadius)) 
    && (iCoordY >= iRadius) && (iCoordY <= (iHight - iRadius)))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    

    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		for(a=-sqrt(2*i);a<=sqrt(2*i);a++)
		{
			for(b=-sqrt(2*i);b<=sqrt(2*i);b++)
			{
				if((int)sqrt(2*i-a*a-b*b)==sqrt(2*i-a*a-b*b))
				{
					c=sqrt(2*i-a*a-b*b);
					if((a-b)+c>=2 && (b-c)+a>=2 && (b-a)+c>=2)
					{
						cnt++;
					}
				}
			}
		}
		printf("%d\n",cnt);
		cnt=0;
	}
		
	return 0;
}

Measured memory_bytes: 2200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll g = 0;
	for (int i = 2; i < n; i++) g ^= a[i];
	ll sum = a[0] + a[1];
	ll dif = sum - g;
	if ((dif & 1) || dif < 0) {
		cout << "-1\n";
		return 0;
	}
	dif /= 2;
	if (dif & g) {
		cout << "-1\n";
		return 0;
	}
	ll bor = a[0] - dif;
	if (bor < 0) {
		cout << "-1\n";
		return 0;
	}
	ll now = 0;
	for (int i = 40; i >= 0; i--) {
		if ((g >> i) & 1) {
			if (now + (1ll << i) <= bor) {
				now += 1ll << i;
			}
		}
	}
	if (now == 0 && dif == 0) cout << "-1\n";
	else cout << bor - now << '\n';
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,l[50],i,x=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	sort(l,l+n);
	for(i=n-1;i>=n-k;i--){
		x+=l[i];
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 1684
N, T = map(int, input().split())
A = [int(i) for i in input().split()]

ml = [(A[-1], 1)]
for a in A[-2:0:-1]:
    n = ml[-1]
    if n[0] == a:
        ml.append((a, n[1] + 1))
    elif n[0] < a:
        ml.append((a, 1))
    else:
        ml.append(n)
ml.reverse()

c = [(ml[i][0] - A[i], ml[i][0], ml[i][1]) for i in range(N - 1)]
c.sort(reverse=True)
max_num = c[0][0]
d = {}
cnt = 0

for m in c:
    if m[0] != max_num:
        break
    cnt += 1
    if m[1] not in d:
        d[m[1]] = m[2]
    else:
        d[m[1]] = max(d[m[1]], m[2])

print(min(cnt, sum(d.values())))

Measured memory_bytes: 77548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
char s[maxx];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int ans = n;
	for(int i = 2; i <= n; i++) {
		if(s[i] == s[i - 1]) {
			ans--;
			s[i + 1] = '#';
		}
	}
	printf("%d\n", ans);
	return 0;
}

/*
aabb -> a ab b
aaab -> a aa b
*/

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,sum=0;
    cin>>k;
    for(i=1;i<=k;i++){

    if(i%3==0&&i%5==0||i%3==0||i%5==0)
        continue;

        else
    {
        sum=sum+i;
    }
    }
    cout<<sum;


}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	var n int
	var s string
	var ans int64

	mp := map[string]int{}

	n = nextInt()

	for i := 0; i < n; i++ {
		s = nextStr()
		slice := strings.Split(s, "")
		sort.Strings(slice)
		s = strings.Join(slice, "")
		ans += int64(mp[s])
		mp[s]++
	}

	fmt.Println(ans)
}

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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int64_t n, m;
    cin >> n >> m;
    vector<int64_t> x(n), y(m);
    for(int i=0; i<n; i++) {
        cin >> x[i];
    }
    for(int j=0; j<m; j++) {
        cin >> y[j];
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int64_t X =0;
    for(int i=0; i<n-1; i++) {
        X += (x[i+1] - x[i]) * (((i+1) * (n-1-i)) % MOD);
        X %= MOD;
    }
    int64_t Y = 0;
    for(int j=0; j<m-1; j++) {
        Y += (y[j+1] - y[j]) * (((j+1) * (m-1-j)) % MOD);
        Y %= MOD;
    }

    cout << X*Y%MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = input()
res = 0
for x in n:
    res += int(x)
    res %= 9
print('Yes' if res == 0 else 'No')

Measured memory_bytes: 10676
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
   ll a,b,c,k;cin>>a>>b>>c>>k;
   ll sum=0;
   sum+=min(k,a);
   k-=min(a,k);
   k-=min(b,k);
   sum-=min(k,c);
   cout<<sum<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3588
# i, jまでの#の数
h,w = map(int,input().split())
sl = []
for _ in range(h):
    s = list(input())
    sl.append(s)

dp = [[float("inf") for i in range(w)] for j in range(h)]
if sl[0][0] == ".":
    dp[0][0] = 0
else:
    dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if j != w-1:
            if sl[i][j+1] != sl[i][j]:
                dp[i][j+1] = min(dp[i][j] + 1, dp[i][j+1])
            else:
                dp[i][j + 1] = min(dp[i][j], dp[i][j + 1])
        if i != h-1:
            if sl[i+1][j] != sl[i][j]:
                dp[i+1][j] = min(dp[i][j] + 1, dp[i+1][j])
            else:
                dp[i+1][j] = min(dp[i][j], dp[i+1][j])
def ceil(a, b):
   return a // b + (a % b > 0)

print(ceil(dp[-1][-1],2))


Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n;
    cin >> n;
    vector<pii> X, Y;
    rep(i, n){
        int m; cin >> m;
        X.push_back(pii(m, i));
    }
    Y = X;
    sort(all(Y));
    vector<bool> flag(n);
    rep(i, n){
        int s = Y[i].second;
        if(i < n/2) flag[s] = 0;
        else flag[s] = 1;
    }
    rep(i, n){
        if(!flag[i]) cout << Y[n/2].first << ln;
        else cout << Y[n/2-1].first << ln;
    }
}

Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int solv(const vector<int>& arr,int mx){
  vector<bool> flgs(mx+1, true);
  // 0, 1 are not prime number. 
  flgs[0] = flgs[1] = false;
  auto sq = ceil(sqrt(mx)+0.1);
  for(auto p = 2;p < sq; p++){
    if(!flgs[p])
      continue;
    for(auto ml = p*p; ml < mx; ml += p){
      flgs[ml] = false;
    }
  }
  int res = 0;
  for(auto n: arr){
    if(flgs[n])
       res++;
  }
  return res;
}
int main(){
  int n, m, mx = 0;
  vector<int> arr;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>m;
    if(m >= mx){
      mx = m;
    }
     arr.push_back(m);  
  }
  cout<<solv(arr, mx+1)<<endl;
  return 0; 
}


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


using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}

	int Ans = 0;
	int min = N;	//こいつを使うことでfor文を2かい回すことを避ける！！！！

	for (int i = 0; i < N; i++) {
		bool ookii = true;
	
		if (P[i] > min) {
			ookii = false;
		}
		if (ookii == true) {
			Ans += 1;
			min = P[i];
		}
	}

	cout << Ans << endl;
}
/*---------以下はfor分を2回回してしまっているのでTLE（実行時間超過）してしまうのでダメな例ーーーーー
int main(void) {
	int N;
	cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}

	int Ans = 0;
	//int min;

	for (int i = 0; i < N; i++) {
		bool ookii = true;
		for (int j = 0; j < i; j++) {
			if (P[i] > P[j]) {
				ookii = false;
			}
		}
		if (ookii == true) {


			Ans += 1;
		}
	}

	cout << Ans << endl;
}*/

Measured memory_bytes: 1024
s_1 = input()
s_2 = input()

memo = [[0 for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]
flag = [[False for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]

for i in range(1, len(s_1)+1):
    memo[i][0] = i
for j in range(1, len(s_2)+1):
    memo[0][j] = j

for i in range(1, len(s_1)+1):
    for j in range(1, len(s_2)+1):
        if not flag[i][j]:
            flag[i][j] = True
            if s_1[i-1] == s_2[j-1]:
                memo[i][j] = min(memo[i-1][j-1], memo[i][j-1]+1)
                memo[i][j] = min(memo[i][j], memo[i-1][j]+1)
            else:
                memo[i][j] = min(memo[i-1][j-1]+1, memo[i][j-1]+1)
                memo[i][j] = min(memo[i][j], memo[i-1][j]+1)

print(memo[len(s_1)][len(s_2)])



Measured memory_bytes: 51576
#include <cstdio>
#include <algorithm>

typedef long long i64;

enum {
  MAXN = 100000 + 5
};

int n, a, b;
int x[MAXN];

void exec() {
  int i;
  i64 ans(0);
  scanf("%d%d%d", &n, &a, &b);
  for (i=0; i<n; ++i)
    scanf("%d", &x[i]);
  for (i=1; i<n; ++i)
    ans += std::min((i64)a*(x[i]-x[i-1]), (i64)b);
  printf("%lld\n", ans);
}

int main() {
  if (fopen("D.in", "r") != NULL) {
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
  }
  exec();
  return 0;
}


Measured memory_bytes: 512
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#endif

void solve(istream& cin, ostream& cout) {
  l n, m;
  cin >> n >> m;
  vb from_a(n);
  vb to_b(n);
  F(i, 0, m) {
    l a, b; cin >> a >> b; a--; b--;
    if (b < a) swap(a, b);
    if (a == 0) from_a[b] = true;
    if (b == n - 1) to_b[a] = true;
  }
  bool ok = false;
  F(i, 1, n - 1) ok = ok or (from_a[i] and to_b[i]);
  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

ll N;
vector<vector<ll>> abc;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	string S;
	cin >> S;

	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	/*
	ll N, W;
	cin >> N >> W;

	vector<ll> w(N), v(N);

	rep(i, N) {
		cin >> w[i] >> v[i];
	}

	vector<vector<ll>> dp(N + 1);
	rep(i, N + 1) dp[i].resize(W + 1);

	for (int i = 0; i < N; i++) {
		for (int weight = 0; weight <= W; weight++) {
			if (weight - w[i] < 0) {
				chmax(dp[i + 1][weight], dp[i][weight]);
			}
			else chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
		}
	}

	/*
	rep(i, N + 1) {
		rep(j, W + 1) {
			cout << to_string(dp[i][j]) + " ";
		}
		cout << endl;
	}*

	cout << dp[N][W] << endl;

	*/

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(a, b):
    if a > b:
        a, b = b, a
    while a > 0:
        a, b = b % a, a
    return b


def lcm(a, b):
    return (a * b) // gcd(a, b)


ans = t[0]
for i in range(1, n):
    ans = lcm(ans, t[i])
print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpp make_pair

using namespace std;

const int N=2e6+5;
const ll infi=1e18+5;

int main()
{
	ll n,i;
	cin>>n;
	vector<string>mp;
	vector<ll>bc;
	string s;
	ll x;
	ll val=0;
	for(i=1;i<=n;i++)
	{
		cin>>s>>x;
		mp.pb(s);
		bc.pb(x);
		val+=x;
	}
	cin>>s;
	ll ans=0;
	for(i=0;i<mp.size();i++)
	{
		if(mp[i]==s){
			ans+=bc[i];
			break;
		}
		ans+=bc[i];
	}

	cout<<val-ans<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long a,b;
   cin>>a>>b;


   if ((a*a-b*b)%(2*a-2*b)==0)
   cout<<(a*a-b*b)/(2*(a-b))<<endl;
   else 
   cout<<"IMPOSSIBLE" <<endl;
   return 0;
}


Measured memory_bytes: 256
from collections import deque

mi = lambda:list(map(int,input().split()))
mix = lambda x:list(mi() for _ in range(x))
##########
def main(n,m,l):
    #グラフの作成
    g = creategraph(n,l)
    #独立した部屋がある場合はNG
    for i in range(1,len(g)):
        if len(g[i]) == 0:
            print("No")
            return
    #BFSで道標を作成
    navi = bfs(n,g)
    #部屋1を除く部屋の道標が更新されていなければNG
    if min(navi[2:]) == 0:
        print("No")
    else:
        print("Yes")
        for i in navi[2:]:
            print(i)

#BFS幅優先探索
def bfs(n,g):
    navi = [0]*(n+1)
    navi[1] = -1
    q = deque()
    q.append(1)
    while len(q) > 0:
        #キューから現在地を取り出す
        cp = q.popleft()
        #現在地の隣接点リストを取得
        np = g[cp]
        #隣接点が未探索ならキューに入れる＋道標更新
        for i in np:
            if navi[i] == 0:
                navi[i] = cp
                q.append(i)
    return navi

#各Nodeの隣接点を保持するリストを生成する
def creategraph(n,l):
    g = {i:[] for i in range(n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    return g

def resolve():
    n,m = mi()
    l = mix(m)
    main(n,m,l)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 66476
#include<stdio.h>
const int N = 305;
const int M = 305;
int main()
{
	int n,m;
	
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2572
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()

	if m > 100000 {
		result := 1

		for i := 2; i <= 100; i ++ {
			if m%i == 0 {
				result = i
			}
		}

		for ; n <= m/99; n++ {
			if m%n == 0 {
				fmt.Println(m / n)
				return
			}
		}
		fmt.Println(result)
		return
	} else {
		for ; n <= m; n++ {
			if m%n == 0 {
				fmt.Println(m / n)
				return
			}
		}
	}

}


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

int main() {

    int n;
    cin >> n;

    vector<int> d(n);

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

    vector<int> num(110, 0);
    for (int i = 0; i < n; i++) {
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; i++) {
        if (num[i] > 0)
            res ++;
    }
    
    cout << res << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N;
    cin>>N;
    long long b[N];
    long long mb=0;
    long long ma=0;
    for(long long i=0;i<N;i++){
    cin>>mb;
    while(mb%2==0){
    ma++;
    mb/=2;}}
    cout<<ma<<endl;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = -1;
    rep(i, n) {
        vector<int> a(26);
        vector<int> b(26);
        rep(j, i + 1) {
            a[s[j] - 'a']++;
        }
        repl(j, i + 1, n) {
            b[s[j] - 'a']++;
        }
        int t = 0;
        rep(j, 26) {
            if(a[j] != 0 && b[j] != 0) t++;
        }
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    from collections import defaultdict
    N = int(input())
    count = defaultdict(int)
    maxcnt = 0
    for _ in range(N):
        s = input()
        count[s] += 1
        maxcnt = max(maxcnt, count[s])
    ss = [s for (s, n) in count.items() if n==maxcnt]
    for s in sorted(ss):
        print(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 33412
s=input().split()
n,m=int(s[0]),int(s[1])
a=input().split()
if n>=m:
    print(0)
else:
    for i in range(m):
        a[i]=int(a[i])
    a.sort()
    #print(a)
    ans=a[-1]-a[0]
    b=[]
    for i in range(m-1):
        b.append(a[i+1]-a[i])
    b.sort()
    for i in range(1,n):
        ans-=b[-i]
    print(ans)

Measured memory_bytes: 10248
#include <iostream>
#include <map>

using namespace std;

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

	map<string, int>m;

	for(int i=0;i<(1<<half);i++){
		string r="", b="";
		for(int j=0;j<half;j++){
			if(i & (1<<j)){
				r = r + s[j];
			}
			else
				b = b + s[j];
		}
		m[r + '.' + b]++;
	}

	long long ans=0;

	for(int i=0;i<(1<<half);i++){
		string r="", b="";
		for(int j=0;j<half;j++){
			if(i & (1<<j)){
				r = s[half + j] + r;
			}
			else
				b = s[half + j] + b;
		}
		ans += 1ll*m[b + '.' + r];
	}

	cout<<ans;
}

Measured memory_bytes: 67968
#include <iostream>

using namespace std;

void solve()
{
	double v;
	while(cin >> v)
	{
		double t = v / 9.8;
		double y = 4.9 * t * t;
		int N = 1;
		while(y > 5 * N - 5)
		{
			++N;
		}
		cout << N << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int aSum = 0, bSum = 0;
		for(int i = 0; i < n; ++i)
		{
			int a, b;
			cin >> a >> b;
			if(a > b)
			{
				aSum += a + b;
			}
			else if(a < b)
			{
				bSum += a + b;
			}
			else
			{
				aSum += a;
				bSum += a;
			}
		}
		cout << aSum << " " << bSum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
n, sum = gets.chomp.split.map(&:to_i)

(0..n).each do |x|
  (0..(n - x)).each do |y|
    z = n - x - y
    next if z < 0 || y < 0 || x < 0

    if sum == 10_000 * x + 5_000 * y + 1_000 * z
      puts "#{x} #{y} #{z}"
      exit
    end
  end
end

puts '-1 -1 -1'


Measured memory_bytes: 3836