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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, K; cin >> a >> b >> c >> K;
    ll ans = a - b;
    if (K % 2 == 1) ans *= -1;
    cout << ans << endl;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
#include <set>

using namespace std;
#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 (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	vector<int>a(9,0);
	rep(i, n) {
		int tmp;
		cin >> tmp;
		if (1 <= tmp && tmp <= 399)a[0]++;
		else if (400 <= tmp && tmp <= 799)a[1]++;
		else if (800 <= tmp && tmp <= 1199)a[2]++;
		else if (1200 <= tmp && tmp <= 1599)a[3]++;
		else if (1600 <= tmp && tmp <= 1999)a[4]++;
		else if (2000 <= tmp && tmp <= 2399)a[5]++;
		else if (2400 <= tmp && tmp <= 2799)a[6]++;
		else if (2800 <= tmp && tmp <= 3199)a[7]++;
		else a[8]++;
	}
	int color = 0;
	int mincolor = 0;
	rep (i, 8) {
		if (a[i] > 0)color++;
	}
	if (color == 0 && a[8] > 0)mincolor = 1;
	else mincolor = color;
	print(mincolor);
	print(color + a[8]);
}

Measured memory_bytes: 3552
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        char t[] = sc.next().toCharArray();

        int max = 3005;
        int dp[][] = new int[s.length + 1][t.length + 1];

        for (int i = 1; i < s.length + 1; i++) {
            for (int j = 1; j < t.length + 1; j++) {
                //System.out.println(s[i-1]+" "+t[j-1]);
                if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
            }
        }

/*
        for (int i = 0; i < s.length + 1; i++) {
            for (int j = 0; j < t.length + 1; j++) {
                System.out.print(dp[i][j] + " ");
            }
            System.out.println();
        }
        
 */


        //System.out.println(dp[s.length][t.length]);

        int inS = s.length;
        int inT = t.length;
        int size = dp[inS][inT];
        String ans = "";

        for(int i=inT;i>0;i--){
            //System.out.println(ans);
            if(dp[inS][i]>dp[inS][i-1]){
                while(true){
                    if(dp[inS][i]>dp[inS-1][i]){
                        //System.out.println(inS+" "+i);
                        ans = s[inS-1]+ans;
                        inS--;
                        break;
                    }
                    inS--;
                }
            }


        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 86604
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
using namespace std;
#define N 10000000000000

int main(){
    long n;
    cin>>n;
    long monster[n+1];
    long people[n];
    for (int i=0; i<=n; i++){
        cin>>monster[i];
    }
    for (int i=0; i<n; i++){
        cin>>people[i];
    }
    long count=0;
    for (int i=0; i<n; i++){
        if (monster[i]>=people[i]){
            monster[i]-=people[i];
            count+=people[i];
        }
        else {
            if (monster[i]+monster[i+1]<=people[i]){
                count+=monster[i];
                count+=monster[i+1];
                monster[i]=0;
                monster[i+1]=0;
            }
            else{
                count+=people[i];
                monster[i+1]=monster[i+1]+monster[i]-people[i];
                monster[i]=0;
            }
        }
    }
    cout<<count<<endl;
}

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

int main(void){
    int n = 0;

    scanf("%d", &n);

    for(int i = 0; i < 26; i++){
        for(int j = 0; j < 15; j++){
            if(i * 4 + j * 7 == n){
                printf("Yes\n");
                return 0;
            }
        }

    }

    printf("No\n");

    return 0;

} 


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,ans=0;cin>>n;
  ans=n%1000;
  if(ans!=0)cout<<1000-ans<<endl;
  else{cout<<0<<endl;}
}






Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll a[n],b= 0,y=0;
	for(int i= 0;i<n; i++)
	{
		cin>>a[i];
		y += a[i];
	}
	ll ans = (ll)(1e17);
	for(int i = 0;i<n-1; i++)
	{
		b+= a[i];
		y-=a[i];
		ans = min(ans,abs(b-y));
		// cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
	cin>>n;
	long long int a[n];
	int i;
	int f=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{f=1;
		}
	}
	long long int sum;
	sum=a[0];
	long long int m=1000000000000000000;
	long long int x=1;
	if(f==1)
	{
		cout<<0<<endl;
	}
	else
	{
	for(i=1;i<n;i++)
	{
		x=m;
		x/=sum;
		x/=a[i];
		if(x==0)
		{
			cout<<-1<<endl;
			break;
		}
		else
		{
			sum*=a[i];
		}
	}
	if(x)
	cout<<sum<<endl;
	}
	return 0;
}



Measured memory_bytes: 4424
n, m = gets.split.map(&:to_i)
k = []
1.upto(m) do |i|
  s = "0" * n
  h = gets.split.map(&:to_i)
  h.shift
  h.each do |j|
    s[j - 1] = "1"
  end
  k[i] = s.to_i(2)
end
p = gets.split.map(&:to_i)
ans = 0
0.upto(2**n - 1) do |i|
  f = 1
  1.upto(m) do |j|
    if (i & k[j]).to_s(2).count("1") % 2 != p[j - 1]
      f = 0
      break;
    end
  end
  ans += f
end
puts ans

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;


signed main() {

	string s;
	cin >> s;
	ll sdash = stoll(s);

	ll ans = sdash;

	rep(bits, 1 << (s.size() - 1)) {
		ll sdashdash = sdash;
		ll aaa = 0;
		bool flag = false;
		for(ll i = 1 ;i < s.size(); i++) {
			if ((bits >> (i - 1)) & 1) {
				ll a = pow(10, i - aaa);
				ans += sdashdash % a;
				sdashdash = sdashdash - (sdashdash % a);
				sdashdash /= a;
				flag = true;
				aaa = i;
				}
		}
		if (flag)ans += sdashdash;
			
	}

	cout << ans;

}


Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
#define YOSHI 102000

struct Node{ int p, l, r;
};

struct Node T[YOSHI];

int n, H, D[YOSHI];
int wowDep(int);
void print(int);

main(){
  int i, j, d, v, c, l,n,m;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  H = 0;
  
  for ( i = 0; i < n; i++ ){
    D[i] = wowDep(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  
  return 0;
}

int wowDep(int a){
  int depth = 0;
  
  for(; T[a].p != NIL ;depth++) a = T[a].p;
  
  return depth;
}
void print(int a){
  int i, c;
  
  printf("node %d: ", a);
  printf("parent = %d, ", T[a].p);
  printf("depth = %d, ", D[a]);

  if ( T[a].p == NIL ) printf("root, ");
  else if ( T[a].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  
  for(i = 0, c = T[a].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  
  printf("]\n");
}



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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N,0);
  vector<int> D(N,0);
  int x=0;
  for(int i=0;i<N;i++){
    cin >> x;
    H.at(i) = max(500*T-3*x-500*A,3*x+500*A-500*T);
    D.at(i) = H.at(i);
  }
  sort(D.begin(),D.end());
  int ans=D.at(0);
  for(int i=0;i<N;i++){
    if(H.at(i) == ans){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ai = Sarray();
            var dct = new Dictionary<long, long>();
            foreach(var a in Ai)
            {
                if (!dct.ContainsKey(a)) dct[a] = 0;
                ++dct[a];
            }
            var numArray = new long[dct.Count];
            var cnt = 0;
            foreach (var d in dct.OrderBy(d => d.Key)) 
                numArray[cnt++] = d.Value;
            var l = 0;
            var r = numArray.Length - 1;
            var rmv = 0L;
            while (l <= r)
            {
                while (l < numArray.Length && numArray[l] == 1)
                    ++l;
                while (0 <= r && numArray[r] == 1)
                    --r;
                if (l < r)
                {
                    var min = Min(numArray[l], numArray[r]) - 1;
                    numArray[l] -= min;
                    numArray[r] -= min;
                    rmv += min * 2;
                }
                if (l == r)
                {
                    if (numArray[l] % 2 == 1)
                        rmv += numArray[l] - 1;
                    else
                        rmv += numArray[l];
                    break;
                }
            }
            WriteLine(N - rmv);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 27488
import time
t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return max(res+10**6, 0)

D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx

p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = T2
    p = p2
else:
    p = p1

i = D-1
next = -1
while time.time()-t1 < 1.9:
    temp = T[i]
    for j in range(1, 27):
        T[i] = j
        newp = calc(T)
        if p < newp:
            p = newp
            temp = j
    T[i] = temp
            
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1

for t in T:
    print(t)

Measured memory_bytes: 69768
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=100010;

int n,a[maxn],b[maxn],c;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)a[i]=read();
    int num=0,ans=0;
    for(int i=1;i<=n;i++){
    	if(a[i]==i)num++;
    	else{
    		ans+=(num+1)/2;
    		num=0;
    	}
    }
    ans+=(num+1)/2;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;
#define LL long long
double p[200];
int t[200];
int v[200];
LL C[100][100];
double dp[105][55];

int main(){
    int n,m,l;
    cin >>  n >> m >> l;
    for(int i = 0;i < n;i++){
        int x,tt,vv;
        scanf("%d%d%d",&x,&tt,&vv);
        p[i] = x / 100.0,t[i] = tt,v[i] = vv;
    }

    for(int i = 0;i <= 50;i++){
        C[i][0] = 1;
        C[i][i] = 1;
        for(int j = 1;j < i;j++){
            C[i][j] = C[i-1][j]+C[i-1][j-1];
            //cout<<C[i][j] << endl;
        }
    }
    for(int i = 0;i < n;i++){
        dp[i][m+1] = 0;
        for(int j = m;j >= 0;j--){ //休息>j次
            dp[i][j] = dp[i][j+1] + C[m][j]*pow(p[i],j)*pow(1-p[i],m-j);
            //cout << dp[i][j] << endl;
        }
    }

    for(int i = 0;i < n;i++){
        double ans = 0;
        if(v[i] != 0){
            for(int j = 0;j <= m;j++){
                double ut = l*1.0/v[i] + j*t[i];
                double pa = C[m][j]*pow(p[i],j)*pow(1-p[i],m-j);
                for(int k = 0;k < n;k++){//?k个人的概率
                    if(k != i){
                        if(v[k] == 0){
                            pa *= 1;
                            continue;
                        }
                        int tim;
                        if(t[k] == 0){
                            if(l*1.0/v[k] <= ut){
                                pa *= 0;
                            }
                            else{
                                pa *= 1;
                            }
                            continue;
                        }
                        tim = floor((ut-(l*1.0/v[k]))/t[k]);
                        while((tim*t[k]+l*1.0/v[k]) <= ut) tim++;
                        if(tim > m){
                            pa *= 0;
                        }
                        else if(tim < 0){
                            pa *= 1;
                        }else{
                            pa *= dp[k][tim];
                        }

                    }
                }
                //printf("%lf\n",pa);
                ans += pa;
            }
        }
        printf("%.8f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,j,sum=0,l;
    cin>>k>>n;
    int ar[n];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    int ans=k;
    for(i=1;i<n;i++)
    {
       ans=min(ans,(k-(ar[i]-ar[i-1])));
//       cout<<ans<<endl;
    }
    ans=min(ans,(k-(ar[0]+k-ar[n-1])));
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  N, A, B;

int main(){
  scanf("%d%d%d",&N,&A,&B);
  int ma = min(A, B);
  int mi = max(0, A + B - N);
  cout << ma << " " << mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;


int main(int argc, const char * argv[]) {

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


	LL K, A, B,diff;

	cin >> K >> A >> B;

	diff = B-A;
	if(diff <= 2){
		cout << 1 + K;
	}else{
		cout << 1 + K + ((K - A + 1) / 2) * ((LL) diff - 2);
	}

	return 0;
}

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

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

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

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

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

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


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

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

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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;

    ll lc = lcm(C,D);

    ll t1 = B/C + B/D - B/lc;  
    ll t2 = (A-1)/C + (A-1)/D - (A-1)/lc;

    pl(B-(A-1) - (t1-t2))  

    return 0;
}


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

long long gcd(long long a, long long b){
 
    long long A = max(a,b);
    long long B = min(a,b);
 
    if(A%B == 0) return B;
    else return gcd(B,A%B);
}

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
  long long A,B;
  cin >> A >> B;
  
  long long G = gcd(A,B);
  double S = sqrt(G);
    long long Ans = 1;

  long long a = 2;
  long long b = 0;
  long long conG = G;
  
	while (conG >= a * a) {
      if(G%a == 0){
     	 G /= a;
        if(b != a){
          Ans++;
          b = a;
        }
      }else{
        a++;
      }
     }
  if(IsPrime(G)) Ans ++;

  cout << Ans << endl;

}


Measured memory_bytes: 256
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(*args):
    # (tuple(map(int, input().split())) for _ in range(N))
    return tuple(p(v) for p, v in zip(args, input().split()))

N = int(input())
A = list(map(int, input().split()))

res = 0
for a in A:
	res += 1 / a
print(1 / res)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    static int gcd(int x, int y) {
        if(x % y == 0) return y;
        else return gcd(y, x % y);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x < y) swap(x, y);
        System.out.println(gcd(x, y));
    }
}


Measured memory_bytes: 26380
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,b,c,d,n,sum_a,sum_c;
    cin >> n >> a >> b >> c >> d;
    
    if(n % a == 0){
        sum_a = n/a*b;
    }
    else{
        sum_a = (n/a+1)*b;
    }
    
    if(n % c == 0){
        sum_c = n/c*d;
    }
    else{
        sum_c = (n/c+1)*d;
    }
    
        
    cout << min(sum_a,sum_c) << endl;
    
    return 0;
}


Measured memory_bytes: 3112
import sys
s = input()
k = int(input())

if len(s) == 1:
    print(int((len(s) * k) / 2))
    sys.exit()


l = 0
while (True):
    if s[l] != s[l+1]:
        break
    if l == len(s) - 2:
        print(int((len(s) * k) / 2))
        sys.exit()
    l += 1



j = 0
counta = 1
while (j<=len(s)-2):
    if s[j] == s[j+1]:
        counta += 1
        j += 1
        continue
    else:
        break


if counta % 2 == 0:
    flaga = 0
else:
    flaga = 1
        


countb = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        s = s[:i+1] + "0" + s[i+2:]
        countb += 1


flagb = 0
if s[len(s)-1] == s[0]:
    if flaga == 1:
        countb += 1
        flagb = 1
        
    


if flagb == 0:
    print(countb * k)
else:
    print(countb * k - 1)










 

 


                                        




    




        


    







        



Measured memory_bytes: 3064
SA = input()
SB = input()
SC = input()
a = b = c = 0
turn = "a"

while(True):
    if turn == "a":
        if a < len(SA):
            turn = SA[a]
            a += 1
        else:
            break
    elif turn == "b":
        if b < len(SB):
            turn  = SB[b]
            b += 1
        else:
            break
    else:
        if c < len(SC):
            turn = SC[c]
            c += 1
        else:
            break

print(turn.upper())

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>


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

int main(){
    
    int n; cin >> n;
    vector<pair<pair<string, int>, int>> r(n);
    
    rep(i, n){
        string s;
        int p;
        cin >> s >> p;
        r[i].first.first = s;
        r[i].first.second = -p;
        r[i].second = i+1;
    }
    sort(r.begin(), r.end());
    
    rep(i, n){
        cout << r[i].second << endl;
    }
    return 0;
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define min(a,b) (a>b)?b:a
#define max(a,b) (a>b)?a:b
#define inf 0x7fffffff
#define ll long long
#define maxn 10005
#define P(a,n) sort(a+1,a+1+n)
#define rt return
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define go continue 
#define clear(vis) memset(vis,0,sizeof vis)
#define end exit(0)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
using namespace std;
ll a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll ans=a*c;
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	printf("%lld",ans);

	return 0;
} 

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int n;cin >> n;
	string str;cin >> str;
	int e = 0;
	int w = 0;
	
	REP(i,str.size()){
		if(str[i] == 'E')e++;
		else w++;
	}
	
	int ans = INF;
	int ne = 0;
	int nw = 0;
	REP(i,str.size()){
		if(str[i] == 'E')ne++;
		ans = min(ans,nw + (e-ne));
		if(str[i] == 'W')nw++;
	}
	
	cout << ans << endl;
		
	
	return 0;
}


Measured memory_bytes: 900
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
const int N=2e5+5;
int n;
void solve(){
	puts("Yes");
	printf("%d %d\n",1,2),printf("%d %d\n",2,3),printf("%d %d\n",3,n+1),printf("%d %d\n",n+1,n+2),printf("%d %d\n",n+2,n+3);
	for(R int i=5;i<=n;i+=2){
		printf("%d %d\n",i-1,i),printf("%d %d\n",i,1),
		printf("%d %d\n",1,n+i-1),printf("%d %d\n",n+i-1,n+i);
	}
	if(n&1^1)printf("%d %d\n",n,n-1),printf("%d %d\n",n+(n^1^(n-1)),n+n);
}
int main(){
	scanf("%d",&n);
	if(n^(n&-n))return solve(),0;
	return puts("No"),0;
}

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

int main() {
	string n;
    cin>>n;
    ll cnt=0;
    for(int i=0;i<n.size();i++){
        cnt+=n[i]-'0';
    }
    if(cnt%9!=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3728
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
a=[0]*(m+1)
for i in range(0,n):
  ka=list(map(int, input().split()))
  for j in range(1,len(ka)):
    a[ka[j]]=a[ka[j]]+1
r=0
for i in range(0,m+1):
  if a[i]==n:
    r=r+1
print(r)



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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M2 - M1 == 1 && D2 == 1) {
    cout << "1" << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}


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

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

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

ll a, b, c, d;

std::map<ll, ll> mp;

ll cost(ll m)
{

    //std::cerr << m << std::endl;

    if (m == 2)
        return std::min(d * 2, a + d);

    if (m == 1)
        return d;

    if (m == 0)
        return 0;

    if (mp.count(m))
        return mp[m];

    ll res = std::min({c + m % 5 * d + cost(m / 5), c + (5 - m % 5) * d + cost(m / 5 + 1), b + m % 3 * d + cost(m / 3), b + (3 - m % 3) * d + cost(m / 3 + 1), a + m % 2 * d + cost(m / 2), a + (2 - m % 2) * d + cost(m / 2 + 1)});

    if (res / d >= m)
    {
        res = std::min(res, d * m);
    }

    return mp[m] = res;
}

int main()
{
    int t;
    std::cin >> t;

    rep(xxx, t)
    {
        mp.clear();
        ll n;
        std::cin >> n;
        std::cin >> a >> b >> c >> d;
        std::cout << cost(n) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4728
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    {
      int s;
      cin>>s;
      cout<<"Case "<<i<<":"<<endl;
      for(int i=0;i<10;i++)
	{
	  int tmp=s*s;
	  tmp/=100;
	  tmp%=10000;
	  s=tmp;
	  cout<<tmp<<endl;
	}
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  string s;
  cin >> s;
  if (s[0] == s[s.size()-1]) {
    cout << s[0] << endl;
  } else {
    cout << 'o' << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
template <typename T>
inline void read(T &x) {
	x = 0;
	bool sign = false;
	char ch = getchar();
	while (ch < '0' || '9' < ch) {
		sign |= ch == '-';
		ch = getchar();
	}
	while ('0' <= ch && ch <='9') {
		x = (x << 3) + (x << 1) + (ch ^ 48);
		ch = getchar();
	}
	x = sign ? -x : x;
}
template <typename T>
inline void print(T x) {
	static char outp[128];
	int tot = 0;
	if (!x) {
		putchar('0');
		return;
	} else if (x < 0) {
		x = -x;
		putchar('-');
	}
	while (x) { outp[tot++] = x % 10, x /=10; }
	while (tot) { putchar(outp[--tot] + 48); }
}
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = f; it <= e; ++it)
#define per(it, f, e) for (rint it = f; it >= e; --it)
const int MAXN = 1e5 + 10;
lint n, m, ans[MAXN];
pii edge[MAXN];
struct Dsu {
	int par[MAXN], val[MAXN];
	inline void clear() {
		rep (i, 1, n) {
			par[i] = i;
			val[i] = 1;
		}
	}
	inline int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}
	inline lint marry(int x, int y) {
		int fx = find(x), fy = find(y);
		cerr << fx << ' ' << fy << endl;
		if (fx == fy) return 0;
		lint v1 = val[fx];
		lint v2 = val[fy];
		lint v3 = v1 + v2;
		val[fx] += val[fy];
		par[fy] = fx;
		return (v3 * (v3 - 1) / 2 - v1 * (v1 - 1) / 2 - v2 * (v2 - 1) / 2);
	}
}	dsu;
int main() {
	read(n), read(m);
	dsu.clear();
	rep (i, 1, m) {
		read(edge[i].fst);
		read(edge[i].sed);
	}
	lint res = n * (n - 1) / 2;
	per (i, m, 1) {
		ans[i] = res;
		res -= dsu.marry(edge[i].fst, edge[i].sed);
	}
	rep (i, 1, m) {
		print(ans[i]);
		newline;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int h1, m1, h2, m2, k;

void read() {
	cin >> h1 >> m1 >> h2 >> m2 >> k;
}

int ans;

void run() {
	ans = 0;
	chkmax(ans, h2 * 60 + m2 - h1 * 60 - m1 - k);
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    S = list(str(input()))
    St = []
    for i in range(N-1):
        if S[i]==S[i+1]:
            continue
        St.append(S[i])
    if S[N-2]==S[N-1]:
        St.append(S[N-2])
    else:
        St.append(S[N-1])
    print(len(St))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B;
  cin >> A >> B;

  if(13 <= A) cout << B << endl;
  else if(6 <= A) cout << B/2 << endl;
  else cout << 0 << endl;
  
  return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int h,w,n;
	cin >> h >> w >> n;

	int m = max(h,w);
	if(n % m == 0) cout << n/m << endl;
	else cout << (n+m-1)/m << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int r;
    cin>>r;
    ll a=3*r*r;
    cout<<a<<endl;



}























































Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int x,a,b;
  cin >> x >> a >> b;
  
  if(abs(x-a)>abs(x-b)) cout << "B" << endl;
  else  cout << "A" << endl;


 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();
			long[] cnt = new long[200010];
			for (int i = 1; i <= n; i++) cnt[i%k]++;

			long ans = 0;
			for (int a = 0; a < k; a++) {
				int b = (k - a) % k;
				int c = (k - a) % k;
				if ((b + c) % k != 0) continue;
				ans += cnt[a] * cnt[b] * cnt[c];
			}
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 24660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (Math.abs(a - c) <= d) {
            System.out.println("Yes");
        } else {
            if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

        }
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a,b;cin>>n;
  bool is_possible=true;
  map<ll,ll> m;
  rep(i,n) {cin>>a>>b;m[b]+=a;}
  ll sum=0;
  for(auto itr:m) {
    sum+=itr.second;
    if(itr.first<sum) is_possible=false;
  }
  print(is_possible?"Yes":"No");
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;

int main(){
	cin>>n;
	int t=0;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		t+=A;
	}
	cout<<(t%2==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

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

using namespace std;
using ll = long long;

int main()
{
	int N;
	cin >> N;
	map<char, int>mp;
	for (int i = 0; i < N; ++i) {
		char h;
		cin >> h;
		mp[h] += 1;
	}

	if (mp['R'] > mp['B'])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
#include <climits>
using namespace std;
typedef long long ll;

int dp[101][101];

void init() {
    for (int i=0; i<101; ++i) {
        for (int j=0; j<101; ++j) {
            if (i == j) {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = INT_MAX;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int,int>> mat(n);
    for (int i=0; i<n; ++i) {
        cin >> mat[i].first >> mat[i].second;
    }

    init();

    for (int l=2; l<=n; ++l) {
        for (int i=0; i<n; ++i) {
            int j = i+l-1;
            if (j > n) continue;
            for (int k=i+1; k<=j; ++k) {
                dp[i][j] = min(dp[i][j], dp[i][k-1] + dp[k][j]
                               + mat[i].first * mat[j].second * mat[k].first);
            }
        }
    }
    cout << dp[0][n-1] << endl;

    return 0;
}

Measured memory_bytes: 1236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.InputMismatchException;


public class Main {
	
	private static int[][] cache;
	private static int[] r;
	private static int[] c;
	

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

		int n = sc.nextInt();
		r = new int[n];
		c = new int[n];

		for (int i = 0; i < n; i++) {
			r[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		// ボトムアップ型３
		cache = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(cache[i], Integer.MAX_VALUE);
			cache[i][i] = 0;
		}

		for (int i = n - 1; i >= 0; i--) {
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < j - i; k++) {
					cache[i][j] = Math.min(cache[i][j], cache[i][i + k] + r[i] * r[i+k+1] * c[j] + cache[i + k + 1][j]);
				}
			}
		}
		int ret = cache[0][n -1];
		
		System.out.println(ret);
		
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;

		private Scanner() {
		}

		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}

		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return st.sval;
		}

		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return (int)st.nval;
		}

		void close() {
		}
	}
}

Measured memory_bytes: 19768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=405;
int dp[N+1][N+1];


    
void solve()
{
int n;
cin>>n;
int a[n+1];int pre[n+1]={0};
for(int i=1;i<=n;i++)
{cin>>a[i];
pre[i]=pre[i-1]+a[i];
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
dp[i][j] =INF;
for(int l=1;l<=n;l++)
{
    for(int i=1;i<=n-l+1;i++)
    {
      int j=i+l-1;
      if(i==j)
      dp[i][j]=0;
      else if(l==2)
      {
          dp[i][j]=a[i]+a[j];
      }
      else
      {
          for(int k=j-1;k>=i;k--)
          dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1]);

      }
      
    }
}
cout<<dp[1][n]<<endl;




}

int32_t main()
{
    //IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 4892