akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    ll ans = 0;
    ll one = min({4 * q, 2 * h, s});
    if(n > 1){
        if(n % 2 == 0){
            if(one * 2 > d){
                ans = (n / 2) * d;
            }else{
                ans = (n / 2) * one * 2;
            }
        }else{
            if(one * 2 > d){
                ans = (n / 2) * d + one;
            }else{
                ans = (n / 2) * one * 2 + one;
            }
        }
    }else{
        ans = one;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public  static int cal(Integer i,int[]visit,int[]dp,HashMap<Integer,ArrayList<Integer>>reversed_edges){
        if(visit[i]==1)return dp[i];
        else{
            dp[i]=0;
            visit[i]=1;
            if(reversed_edges.containsKey(i)){
                for(Integer m:reversed_edges.get(i)){
                dp[i]=Math.max(dp[i],cal(m,visit,dp,reversed_edges)+1);
                }
            }
        }
        return dp[i];
    }
    public static void main(String[] args){
        int N,M,x,y,res=0;
        Scanner in=new Scanner(System.in);
        N=in.nextInt();
        M=in.nextInt();
        int[]dp=new int[N+1];//dp[i]:以i为终点的最长路径
        int[] visit=new int[N+1];
        HashMap<Integer,ArrayList<Integer>>reversed_edges=new HashMap<>();
        visit[0]=1;
        for(int i=1;i<=M;i++){
            x=in.nextInt();
            y=in.nextInt();
            if(!reversed_edges.containsKey(y))reversed_edges.put(y,new ArrayList<>());
            reversed_edges.get(y).add(x);
        }
        for(int i=1;i<=N;i++){
            if(reversed_edges.containsKey(i)){
            for(Integer m:reversed_edges.get(i)){
                dp[i]=Math.max(dp[i],cal(m,visit,dp,reversed_edges)+1);
            }
            }
        }
        for(int i=1;i<=N;i++)res=Math.max(res,dp[i]);
        System.out.println(res);
    }
}



Measured memory_bytes: 129664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    int N; cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int a = L[i], b = L[j];
            auto it = lower_bound(L.begin(), L.end(), b + a);
            ans += it - (L.begin() + j + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  m, _ := strconv.Atoi(sc.Text())

  cnt := make(map[int]int)
  l := make([]int, 0, 100000000)

  for i := 0; i < n; i++ {
    sc.Scan()
    a, _ := strconv.Atoi(sc.Text())
    if _, ok := cnt[a]; !ok {
      l = append(l, a)
    }

    cnt[a] += 1
  }

  for i := 0; i < m; i++ {
    sc.Scan()
    b, _ := strconv.Atoi(sc.Text())

    sc.Scan()
    c, _ := strconv.Atoi(sc.Text())

    if _, ok := cnt[c]; !ok {
      l = append(l, c)
    }

    cnt[c] += b
  }

  sort.Sort(sort.Reverse(sort.IntSlice(l)))

  sum := 0
  for _, v := range l {
    if n - cnt[v] < 0 {
      sum += v * n
      break
    } else {
      sum += v * cnt[v]
      n -= cnt[v]
    }
  }
  fmt.Println(sum)
}



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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";
#define int long long

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}
int ways[3005][3005];
int a[3005];
int32_t main() {
	int n,s; cin>>n>>s;
	for(int i=1;i<=n;i++) cin>>a[i];

	int ans=0,mod=998244353;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=s;j++) ways[i][j]=ways[i-1][j];

		if(a[i]>s) continue;
		ways[i][0]=i;
		int val=ways[i][s-a[i]]*(n-(i-1));
		// cout<<i<<" "<<ways[i][s-a[i]]<<endl;
		ans=(ans+val)%mod;

		ways[i][a[i]]=(ways[i][a[i]]+i)%mod;
		for(int j=1;j<=s-a[i];j++){
			ways[i][j+a[i]]=(ways[i][j+a[i]]+ways[i-1][j])%mod;
		}
		// ways[i]
		// for(int i=)
	}
	cout<<ans;

}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		if (x < a) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}
}

Measured memory_bytes: 23636
#akash mandal: jalpaiguri government engineering college
#take a look on special cases: test cases
import sys,math

def ii(): return int(input())
def mii(): return map(int,input().split())
def lmii(): return list(mii())


def main():
    n=ii()
    pi=3.141592653589793
    r=2*pi*n
    print ('%.20f'%r)
    
        
            
        
            
            
        
            
    
        
        
     
        
if __name__=="__main__":
    main() 

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

#define int long long int


signed main(){

  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=1;i<n;i++){
    if(a[i]<a[i-1]){
      ans+=(a[i-1]-a[i]);
      a[i]=a[i-1];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5152
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var k = (int)h[1];
		var s = new int[h[0]].Select(_ => read()).OrderByDescending(x => x[1]).ToArray();

		var s0 = s.Take(k).ToArray();
		var g0 = s0.ToLookup(x => x[0], x => x[1]);
		var l0 = g0.SelectMany(g => g.Skip(1)).OrderBy(x => x).ToList();
		var l1 = s.Skip(k).Where(x => !g0.Contains(x[0])).GroupBy(x => x[0]).Select(g => g.First()[1]).OrderByDescending(x => x).ToList();

		long r = s0.Sum(x => x[1]) + (long)g0.Count * g0.Count, M = r;
		for (int i = 0; i < l0.Count && i < l1.Count; i++) M = Math.Max(M, r += l1[i] - l0[i] + 2 * (g0.Count + i) + 1);
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 38200
#include<iostream>
#include "algorithm"
#include "bits/stdc++.h"
using namespace std ;
int n,k;
int a[1050];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    long long sum=0;
    for(int i=0;i<k;i++)
        sum+=a[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll N,M;
	ll ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N>>M;
	cout<<abs((N-2)*(M-2))<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int a,b,c;
int x[9];

int main(){
	scanf("%d%d%d" , &a , &b , &c);
	repp(i,0,10000){
		x[0] = a;
		x[1] = b;
		x[2] = i;
		x[4] = c;
		int s = a+b+i;
		x[7] = s-b-c;
		x[8] = s-a-c;
		x[5] = s-i-x[8];
		x[3] = s-x[4]-x[5];
		x[6] = s-x[7]-x[8];
		if(x[0]+x[3]+x[6]==s&&x[2]+x[4]+x[6]==s){
			repp(j,0,9){
				printf("%d%c" , x[j] , j%3==2?'\n':' ');
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    rep(q, k){
        vector<int> b(n+1);
        rep(i, n){
            b[max(0, i-a[i])] += 1;
            b[min(n, i+a[i]+1)] -= 1;
        }
        REP(i, n)b[i] += b[i-1];
        bool ok = true;
        rep(i, n){
            a[i] = b[i];
            if(a[i] < n)ok = false;
        }
        if(ok)break;
    }
    rep(i, n)cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 4844
#include<iostream>

using namespace std;


int main() {
	int N;
	const int ARRAY_SIZE = 101;
	//配列をglobal変数とすると、int flag[101]だけですべてが0に初期化される。
	//配列の各要素を0で初期化したい時は、{}を使うとよい。
	//要素数が10で{3, 2, 5}で初期化すると、残りの要素を0で初期化してくれる。
	int flag[ARRAY_SIZE] = {};

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

	int ans = 0;
	for (int i = 0; i < 101; i++) {
		ans += flag[i];
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int nums=sc.nextInt();
		int[] arr= new int[nums];
		for(int i=0;i<nums;i++) {
			arr[i]=sc.nextInt();
		}
		int num=0;
		for(int i=0;i<arr.length-2;i++) {
			if(arr[i]>arr[i+1]) {
				if(arr[i+1]>arr[i+2]) {
					num++;
				}
			}else if(arr[i]<arr[i+1]) {
				if(arr[i+1]<arr[i+2]) {
					num++;
				}
			}
		}
		System.out.println(num);
		
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <limits>
#include <queue>
#include <vector>

#define REPI(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPD(i, n) for (int i = static_cast<int>(n); i >= 0; --i)
#define FOR(i, c) for (auto i : (c))
#define FOR_REF(i, c) for (auto &i : (c))
#define ALL(c) (c).begin(), (c).end()
#define LEN(c) static_cast<int>((c).size())

#define IO_SETUP                                                               \
  std::cin.tie(nullptr);                                                       \
  std::ios::sync_with_stdio(false);

#define SEE(i) std::cerr << #i << ": " << i << " at: (" << __LINE__ << ")\n";

int main() {
  using namespace std;
  IO_SETUP;
  constexpr int SIZ = 300001;
  int n;
  cin >> n;
  int a[SIZ] = {}, b[SIZ] = {};
  string s;
  cin >> s;
  REPI(i, n) {
    if (i == 0) {
      a[i] = (s[i] == 'W' ? 1 : 0);
      continue;
    }
    a[i] = a[i - 1] + (s[i] == 'W' ? 1 : 0);
  }
  REPD(i, n - 1) {
    if (i == n - 1) {
      b[i] = (s[i] == 'E' ? 1 : 0);
      continue;
    }
    b[i] = b[i + 1] + (s[i] == 'E' ? 1 : 0);
  }
  int val = n;
  REPI(i, n) { val = min(val, a[i] + b[i]); }
  cout << val - 1;
  return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a, b;
        cin >> a >> b;
        cout << (a * b) / __gcd(a, b) << '\n';
    }
}

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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int ans = min(P + Q, min(Q + R, R + P));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#define N 200

int main(){
  int n,i,j,k,l,v[N][N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      v[i][j]=0;
    }
  }
  for(i=1;i<n+1;i++){
    scanf("%d%d",&v[i][0],&k);
    v[i][0]+=k;
    for(j=1;j<v[i][0]-i+1;j++){
      scanf("%d",&l);
      v[i][l]++;
    }
  }
  for(i=1;i<n+1;i++){
    for(j=1;j<n;j++){
      printf("%d ",v[i][j]);
    }
    printf("%d\n",v[i][j]);
  }
  return 0;
}

Measured memory_bytes: 680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    set<int> s;
    for (int i = A; i < min(A + K, B + 1); i++)
    {
        s.insert(i);
    }
    for (int i = max(A, B - K + 1); i <= B; i++)
    {
        s.insert(i);
    }
    for (int i : s)
    {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<int> res(N);
    for (int i = 0; i < N - 1; i++) {
        int a;
        cin >> a;
        res[a - 1]++;
    }

    for (int i = 0; i < N; i++) {
        cout << res[i] << endl;
    }

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

using namespace std;

const ll MOD=1000000007;

const int N_BIN=2000;
ll nCr[N_BIN+1][N_BIN+1];
void binom(){
	rep(n,N_BIN+1) nCr[n][0]=1;
	rep(n,N_BIN) rep(r,n+1) nCr[n+1][r+1]=(nCr[n][r+1]+nCr[n][r])%MOD;
}

int main(){
	binom();

	int n,k; cin>>n>>k;
	for(int i=1;i<=k;i++) cout<<nCr[n-k+1][i]*nCr[k-1][i-1]%MOD<<endl;

	return 0;
}


Measured memory_bytes: 30080
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


X = int(input())

while True:
    x = prime_factorize(X)
    if len(x) == 1:
        print(X)
        break
    else:
        X += 1


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-6;


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

    string s; cin >> s;
    int n = s.size();

    vi a(n+1);
    int tmp = 1;
    RREP(i, n) {
        a[i] = (a[i+1] + tmp * (s[i] - '0')) % 2019;
        (tmp *= 10) %= 2019;
    }

    map<int,ll> cnt;
    REP(i, n+1) {
        ++cnt[a[i]];
    }

    ll ans = 0;
    for (auto& tp : cnt) {
        ans += tp.second * (tp.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


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

#define ll long long

signed main()
{
  int A,B;
  cin >> A >> B;
  if(A==1){A += 13;}
  if(B==1){B += 13;}

  if(A>B){cout << "Alice";}
  else if(B>A){cout << "Bob";}
  else{cout << "Draw";}
}

Measured memory_bytes: 3636
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.IntMap.Strict as M
import Data.List
import Control.Monad

readInput :: IO [Int]
readInput = map (either error fst . T.decimal) . T.words <$> T.getLine

main = do
  count <- readLn
  xs <- readInput
  let nums = M.fromList $ zip [1..] xs
  let counts = M.fromListWith (+) [ (i, 1) | i <- xs ]
  let totals = M.map (\n -> if n < 2 then 0 else n * (n - 1)) counts
  let grand = foldl' (+) 0 totals
  forM_ [1..count] $ \i -> do
    print $ max 0 $ div grand 2 - counts M.! (nums M.! i) + 1


Measured memory_bytes: 78588
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using litn = lint;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()


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

    vec<string> d(4);
    d = {"dream","dreamer","erase","eraser"};
    reverse(all(s));
    REP(i,4) reverse(all(d[i]));

    string ans="YES";
    for(int i=0;i<s.size();){
      bool bl=false;
      REP(j,4){
        if(s.substr(i,d[j].size()) == d[j]){
          bl=true;
          i += d[j].size();
        }
      }
      if(!bl){
        ans = "NO";
        break;
      }
    }

    cout <<ans <<endl;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

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

        int n = sc.nextInt();

        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0, bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alice += a[i];
            } else {
                bob += a[i];
            }
        }

        System.out.println(alice - bob);
    }
}

Measured memory_bytes: 21844
n,m,x=map(int,input('').split(' '))
c=[]
a=[]
for k in range(n):
    s=input('')
    s=s.split(' ')

    c.append(int(s[0]))
    kara=[]
    for l in range(len(s)-1):
        kara.append(int(s[l+1]))
    
    a.append(kara)

b=[]
for k in range(n):
    b.append(0)

lx=[]
for k in range(m):
    lx.append(0)

able=0
mcos=100000000000000000
while b[n-1]!=2:
    cost=0

    for k in range(m):
        lx[k]=0
    
    for k in range(n):
        if b[k]==1:
            for j in range(m):
                lx[j]+=a[k][j]
            cost+=c[k]
    
    ok=1
    for k in range(m):
        if lx[k]>=x:
            ok=ok*1
        else:
            ok=ok*0
        
    if ok==1 and cost<=mcos:
        able=1
        mcos=cost
    
    b[0]+=1
    for k in range(n-1):
        if b[k]==2:
            b[k]=0
            b[k+1]+=1

if able==1:
    print(mcos)
else:
    print(-1)

Measured memory_bytes: 9300
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n-1; i++) {
            a[sc.nextInt()-1]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }

}

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

int main(){
  ll n,k,r,s,p,sum=0;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  for(int i=0; i<t.size(); i++){
    if(i>=k && t[i]==t[i-k]) t[i] = '0';
    if(t[i]=='r') sum += p;
    if(t[i]=='s') sum += r;
    if(t[i]=='p') sum += s;
  }
  cout<<sum;
}

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

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

  if (D == 25){
    cout << "Christmas" << endl;
  }
  else if (D == 24)
  {
    cout << "Christmas Eve" << endl;
  }
  else if (D == 23)
  {
    cout << "Christmas Eve Eve" << endl;
  }
  else
  {
    cout << "Christmas Eve Eve Eve";
  }
  
  
  
}

Measured memory_bytes: 3560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: i64,
        x: i64,
        y: i64
    }
    let mut count:Vec<u64> = vec![0;(n-1) as usize];
    for i in 1..n {
        for j in i+1..n+1 {
            count[(min(&(j-i), &min(&(abs(&x, &i) + abs(&j, &y) + 1), &(abs(&y, &i) + abs(&j, &x) + 1))) - 1) as usize] += 1;
        }
    }
    for i in count.iter(){
        println!("{}", i)
    }
}


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

int main(){
  long long a, b, c, d;
  long long cnt = 0;
  cin >> a >> b >> c >> d;

  long long c_t, d_t, r;
  c_t = c;
  d_t = d;

  if(c_t < d_t){
    swap(c_t, d_t);
  }

  r = c_t % d_t;

  while(r!=0){
    c_t = d_t;
    d_t = r;
    r = c_t % d_t;
  }
  long long x = (c * d)/d_t;

  long long A, B, C;
  A = (b/c - a/c);
  if (a % c == 0) {
    A = A + 1;
  }

  B = (b/d - a/d);
  if (a % d == 0) {
    B = B + 1;
  }
  C = (b/x - a/x);
  if (a % x == 0) {
    C = C + 1;
  }

  cout << (b-a+1) - (A + B - C) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int n = Integer.parseInt(sc.next());
  int a = Integer.parseInt(sc.next());
  int ans = n%500;
  if (ans <= a){
    System.out.println("Yes");
  }
  else {
    System.out.println("No");
  }
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


vector<ll>a;
ll gcd(ll l,ll r){
	if(r==0){
		return l;
	}
	return gcd(r,l%r);
}
int main() {
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll GCD=a[0];
	for(int i=1;i<n;i++){
		GCD=gcd(max(GCD,a[i]),min(GCD,a[i]));
	}
	for(int i=0;i<n;i++){
		if(a[i]>=k){
			if((a[i]-k)%GCD==0){
				cout << "POSSIBLE";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE";
	// your code goes here
	return 0;
}

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

using namespace std;

#define N_CONTEST   (26)
#define N_DAY       (365)

static void get_input (int &D, vector<int> &c, vector<vector<int>> &s) {
    cin >> D;
    assert(D == N_DAY);
    for ( int i = 1; i <= N_CONTEST; i++ ) {
        cin >> c.at(i);
    }
    for ( int i = 1; i <= N_DAY; i++ ) {
        for ( int j = 1; j <= N_CONTEST; j++ ) {
            cin >> s.at(i).at(j);
        }
    }
}

//static long long calc_score (vector<int> &c, vector<vector<int>> &s, vector<int> &t) {
//    vector<int> last(N_CONTEST+1, 0);
//
//    long long score = 0;
//
//    for ( int d = 1; d <= N_DAY; d++ ) {
//        score += s.at(d).at(t.at(d));
//        last.at(t.at(d)) = d;
//        for ( int con = 1; con <= N_CONTEST; con++ ) {
//            score -= c.at(con) * (d - last.at(con));
//        }
//        cout << score << endl;
//    }
//
//    return score;
//}

static int calc_greedy_ans (vector<int> &c, vector<vector<int>> &s, vector<int> &last, int day) {
    int max_score = INT_MIN;
    int ans_c = 1;

    for ( int con = 1; con <= N_CONTEST; con++ ) {
        int score = s.at(day).at(con);
        for ( int con = 1; con <= N_CONTEST; con++ ) {
            score -= c.at(con) * (day - last.at(con));
        }
        if ( score > max_score ) {
            max_score = score;
            ans_c = con;
        }
    }

    last.at(ans_c) = day;

    return ans_c;
}

int main (void) {
    int D;
    vector<int> c(N_CONTEST+1);
    vector<vector<int>> s(N_DAY+1, vector<int>(N_CONTEST+1, 0));

    get_input(D, c, s);

    vector<int> last(N_CONTEST+1, 0);
    for ( int d = 1; d <= N_DAY; d++ ) {
        int greedy_c = calc_greedy_ans(c, s, last, d);
        cout << greedy_c << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := uint32(getNextInt64(scanner))
	fmt.Fprintln(writer, fmt.Sprintf("%032b", x))
	fmt.Fprintln(writer, fmt.Sprintf("%032b", math.MaxUint32^x))
	fmt.Fprintln(writer, fmt.Sprintf("%032b", x<<1))
	fmt.Fprintln(writer, fmt.Sprintf("%032b", x>>1))
}



Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) ); 
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n; cin >> n;
  int l=1;
  int d=1;
  vector<vector<int>> lr(10, vector<int>(10,0));
  bool isend = false;
  rep(i,6){
    repz(l,1,10){
      repz(k,l*d,(l+1)*d){
        if(k>n){
          isend = true;
          break;
        }
        int r=k%10;
        if(k<10) lr[k][r]++;
        else lr[l][r]++;
        // debug(i,l,r,k);
      }
      if(isend) break;
    }
    if(isend) break;
    d*=10;
  }
  ll res=0;
  rep(r,10){
    rep(l,10){
      if(r<=l and lr[r][l]>0) debug(l,r,lr[r][l], lr[l][r]);
      if(r==l) res+=lr[r][l]*lr[l][r];
      if(r<l) res+=lr[r][l]*lr[l][r]*2;
    }
  }
  cout << res << endl;

  return 0;
}


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



#define N_MAX 20
#define M_MAX 30

struct MAPS { int y; int x; };
struct COMMAND { char direction; int step; };


int main(int argc, char **argv)
{
	int N;
	int M;
	char map[21][21];
	struct MAPS gem[N_MAX];
	struct COMMAND command[M_MAX];
	struct MAPS robot = { 10, 10 };
	int gembag = 0;
	int counti, countj;
	char inputline[10];
	
	for (counti = 0; counti < 20; counti++){
		for (countj = 0; countj < 20; countj++){
			map[counti][countj] = 0;
		}
	}
	
	
	while( 1 ){
		fgets( inputline, sizeof( inputline ), stdin );
		sscanf( inputline, "%d", &N );
		if (N == 0) break;
		for( counti = 0; counti < N; counti++){
			fgets( inputline, sizeof( inputline ), stdin );
			sscanf( inputline, "%d%d", &gem[counti].x, &gem[counti].y );
		}
		
		fgets( inputline, sizeof( inputline ), stdin );
		sscanf( inputline, "%d", &M );
		for ( counti = 0; counti < M; counti++ ){
			fgets( inputline, sizeof( inputline ), stdin );
			sscanf( inputline, "%c%d", &command[counti].direction, &command[counti].step );
		}
		
		
		for ( counti = 0; counti < N; counti++ ){
			map[gem[counti].y][gem[counti].x] = 1;
		}
		
		for(counti = 0; counti < M; counti++){
			switch (command[counti].direction)
			{
				case 'N':
					for( countj = 0; countj < command[counti].step; countj++){
						robot.y++;
						if( map[robot.y][robot.x] == 1 ){
							map[robot.y][robot.x] = 0;
							gembag++;
						}
					}
					break;
				case 'E':
					for( countj = 0; countj < command[counti].step; countj++){
						robot.x++;
						if( map[robot.y][robot.x] == 1 ){
							map[robot.y][robot.x] = 0;
							gembag++;
						}
					}
					break;
				case 'W':
					for( countj = 0; countj < command[counti].step; countj++){
						robot.x--;
						if( map[robot.y][robot.x] == 1 ){
							map[robot.y][robot.x] = 0;
							gembag++;
						}
					}
					break;
				case 'S':
					for( countj = 0; countj < command[counti].step; countj++){
						robot.y--;
						if( map[robot.y][robot.x] == 1 ){
							map[robot.y][robot.x] = 0;
							gembag++;
						}
					}
					break;
			}
		}
		if( gembag == N ){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
		
		for ( counti = 0; counti < N; counti++ ){
			map[gem[counti].y][gem[counti].x] = 0;
		}
		gembag = 0;
		robot.x = 10;
		robot.y = 10;
	}
	
	
	return 0;

}

Measured memory_bytes: 1680
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;

  n %= k;

  cout << min(n,abs(n-k)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if ((a + d - 1) / d >= (c + b - 1) / b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 3648
use std::cmp::{max, min};
use std::io::*;
use std::str::FromStr;

fn main() {
    let (n, m): (usize, usize) = (read(), read());
    let (x, y): (i32, i32) = (read(), read());
    let xmax = (0..n).map(|_| read::<i32>()).max().unwrap();
    let ymin = (0..m).map(|_| read::<i32>()).min().unwrap();
    println!(
        "{}",
        if max(x, xmax) < min(y, ymin) {
            "No War"
        } else {
            "War"
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	long long N;
    long long A, B;
    cin >> N >> A >>  B;
    long long AB = A + B;
    if(AB == 0) return 0;
    
    long long m = N % AB;
    if(A < m) m = A;
    
    long long S = A * (N / AB) + m;
    
	cout << S << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
    int a,b,c,k; cin>>a>>b>>c>>k;
    int f = a-b;
    int tmp = a, tmp2 = b;
    a=b+c; b=tmp+c; c= tmp+tmp2;
    int s = a-b;
    if(abs(f)==abs(s)){
        if(k%2==1) { if(abs(s)>1000000000000000000LL) cout<<"Unfair"<<endl; else cout<<s<<endl;}
        else { if(abs(f)>1000000000000000000LL) cout<<"Unfair"<<endl; else cout<<f<<endl;}
    }else{
        cout<<"Unfair"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

using T = pair<int,int>;
T INF = {1e9,1e9};
class RMQ{
    int N;
    vector<T> dat;

    T impl(int l,int r,int k,int a,int b){
        if(l<=a && b<=r) return dat[k];
        if(r<=a || b<=l) return INF;
        int mid = (a+b)/2;
        return min(impl(l,r,k*2+1,a,mid),impl(l,r,k*2+2,mid,b));
    }    
    public:
    RMQ(int n){
        N=1;
        while(N<n) N*=2;
        dat.resize(2*N-1,INF);
    }
    void update(int pos,T v){
        pos+=N-1;
        dat[pos] = v;
        while(pos){
            int par = (pos-1)/2;
            int c1 = par*2+1;
            int c2 = par*2+2;
            dat[par]=min(dat[c1],dat[c2]);
            pos =par;
        }
    }
    T get(int pos){
        return dat[pos+N-1];
    }

    T query(int l,int r){
        return impl(l,r,0,0,N);
    }

};

using Graph=vector<vector<int>>;

struct Query{
    char qtype;
    int t;
    int v;
};

ll dfs(int v,int height,Graph& g,vector<vector<Query>>& qs,RMQ& rmq){
    stack<pair<int,T>> st;
    ll res = 0;
    for(auto q:qs[v]){
        if(q.qtype=='M'){
            st.push({q.t,rmq.get(q.t)});
            rmq.update(q.t,{height,q.v});
        }
        else{
            // cerr<<0<<" "<<q.t<<" "<<v<<endl;
            // cerr<<q.t<<" "<<rmq.query(0,q.t).second+1<<endl;
            res+=rmq.query(0,q.t).second+1;
        }
    }
    for(auto to:g[v]){
        res+=dfs(to,height-1,g,qs,rmq);
    }
    while(!st.empty()){
        auto tmp = st.top(); st.pop();
        rmq.update(tmp.first,tmp.second);
    }
    return res;
}
void solve(int n,int q){
    Graph g(n);
    for(int i=1;i<n;i++){
        int p;
        cin>>p; p--;
        g[p].push_back(i);
    }
    vector<vector<Query>> qs(n);
    for(int i=0;i<q;i++){
        Query qu;
        cin>>qu.qtype>>qu.v;
        qu.v--;
        qu.t = i+1;
        qs[qu.v].push_back(qu);
    }
    RMQ rmq(q+1);
    rmq.update(0,T{n,0});
    cout<< dfs(0,n,g,qs,rmq)<<endl;
}
int main(){
    int n,q;
    while(cin>>n>>q,!(n==0 && q==0)){
        solve(n,q);
    }
    return 0;
}



Measured memory_bytes: 117984
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val h = sc.nextInt()
  val w = sc.nextInt()
  val k = sc.nextInt()
  val c = Array(h) { sc.next().toCharArray() }

  var count = 0
  for (hBit in 0 .. (1 shl h) - 1) {
    for (wBit in 0 .. (1 shl w) - 1) {
      var black = 0

      for (i in 0 until h) {
        for (j in 0 until w) {
          if ((hBit shr i) and 1 == 0 && (wBit shr j) and 1 == 0) {
            if (c[i][j] == '#') {
              black++
            }
          }
        }
      }

      if (black == k) count++

    }
  }

  println(count)

}


Measured memory_bytes: 36460
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

int main() {
  lint N,K;
  cin >> N >> K;
  lint ans = 0;
  lint mod = 1000000007;
  lint term = 1;
  for (lint i=1; i<N+2; i++) {
    term += N;
    term += mod;
    term -= (i-1)*2;
    term %= mod;
    if (i >= K) {
      ans += term;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
// const ll mod=1000000007;
const ll mod=998244353;

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}

int main(){
  startupcpp();
  ll i,N,A,B,K,ans=0;
  cin>>N>>A>>B>>K;
  i=gcd(A,B);
  A/=i;B/=i;K/=i;
  rep(i,N+1){
    if(K<0)break;
    if(K%B==0&&K<=N*B){
      ans+=modncr(N,i)*modncr(N,K/B)%mod;
    }
    K-=A;
  }
  print(ans%mod);
}

Measured memory_bytes: 4992
import fractions
a,b,c,d = map(int,input().split())
diff_c = b//c - (a-1)//c
diff_d = b//d - (a-1)//d
lcm_cd = int(c*d/fractions.gcd(c,d))
diff_cd = b//(lcm_cd) - (a-1)//(lcm_cd)
print((b-a+1)-(diff_c+diff_d-diff_cd))

Measured memory_bytes: 5048