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

using namespace std;

template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}

int main()
{
   /* #ifdef Ak
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    */
   
   long long int i,j,ans,n,x,l,r,mid;
   
   cin>>x;
   
   for(i=0;i<100005;i++)
   {
       ans=i;
       ans*=(i+1);
       ans/=2;
       if(ans>=x)
       {
           break;
       }
   }
   
   cout<<i;
   
    return 0;
    
}


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

int main(){
    long long a,b,c,d, ac, ad, bc, bd, ans;
    cin >> a >> b >> c >> d;
    ans = b * d;
    if (ans < b * c) ans = b * c;
    if (ans < a * c) ans = a * c;
    if (ans < a * d) ans = a * d;
    cout << ans << endl;
}


Measured memory_bytes: 3632
def main():
    import collections
    H, W = map(int, input().split())
    s = [list(input()) for i in range(H)]
    t = [[0]*W for i in range(H)]
    if s[0][0] == "#":
        t[0][0] = 1

    for i in range(1, W):
        t[0][i] = t[0][i-1]
        if s[0][i] == "#" and s[0][i-1] == ".":
            t[0][i] += 1
    for i in range(1, H):
        t[i][0] = t[i-1][0]
        if s[i][0] == "#" and s[i-1][0] == ".":
            t[i][0] += 1

    for i in range(1, H):
        for j in range(1, W):
            k = 0
            l = 0
            if s[i][j] == "#":
                if s[i-1][j] != "#":
                    k += 1
                if s[i][j-1] != "#":
                    l += 1
            t[i][j] = min(t[i-1][j] + k, t[i][j-1]+l)

    print(t[-1][-1])


main()


Measured memory_bytes: 41456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<string> s(3);
  rep(i, 3) cin >> s[i];

  rep(i, 3) cout << s[i][i];
  cout << endl;


  
  return 0;
}

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

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26732
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll x;
    cin>>x;
    ll p=0;
    for(ll i=-1000;i<=1000;i++)
    {
    	for(ll j=-1000;j<=1000;j++)
    	{
    		p=pow(i,5)-pow(j,5);
    		if(x==p)
    		{
    			cout<<i<<" "<<j<<"\n";
    			return;
    		}
    	}
    }
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

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

  sort(v,v+n);
  double mix=v[0];
  rep(i,n-1){
    mix=(mix+v[i+1])/2;
  }
  cout << mix << endl;
}


Measured memory_bytes: 3760
#include <cstring>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
 
#include <queue>
#include <iostream>
#include <set>
using namespace std;
 
vector<int> s;
 
int memo[100][100][2];
 
int solve(int f, int e, int t){
  if(f == e) return s[f];
  if(f + 1 == e) return t;
  if(memo[f][e][t] != -1)
    return memo[f][e][t];
 
  int ret = !t;
 
  if(s[e] != t || s[f] != t){
    if(s[e] != t)
      if(t == solve(f, e - 1, !t))
        ret = t;
    if(s[f] != t)
      if(t == solve(f + 1, e, !t))
        ret = t;
  }else{
    ret = solve(f, e, !t);
  }
 
  // printf("%d %d %d: %d\n", f, e, t, ret);
 
  return memo[f][e][t] = ret;
}
 
int main(){
  string c;
 
  cin >> c;
 
  char prev = 's';
 
  memset(memo, -1, sizeof(memo));
 
  REP(i,c.size()){
    if(c[i] == prev) continue;
    prev = c[i];
    s.push_back(c[i] == 'o' ? 0 : 1);
  }
 
  int win = solve(0, s.size() - 1, 0);
 
  puts(win == 0 ? "o" : "x");
 
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i, j;
	char a[1003][1003];
	for (i = 0; i < h; i++)
		scanf("%s", a[i]);
	int c[1003][1003];
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (a[i][j] == '#')
				c[i][j] = 0;
			else
				c[i][j] = 1000000009;
		}
	}
	for (i = 0; i < h; i++)
		for (j = 1; j < w; j++)
			if (c[i][j] > c[i][j - 1] + 1)
				c[i][j] = c[i][j - 1] + 1;
	for (i = 0; i < h; i++)
		for (j = w - 2; j >= 0; j--)
			if (c[i][j] > c[i][j + 1] + 1)
				c[i][j] = c[i][j + 1] + 1;
	for (j = 0; j < w; j++)
		for (i = 1; i < h; i++)
			if (c[i][j] > c[i - 1][j] + 1)
				c[i][j] = c[i - 1][j] + 1;
	for (j = 0; j < w; j++)
		for (i = h - 2; i >= 0; i--)
			if (c[i][j] > c[i + 1][j] + 1)
				c[i][j] = c[i + 1][j] + 1;
	int ans = 0;
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (ans < c[i][j])
				ans = c[i][j];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5120
def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


N, P = map(int, input().split())
fac = factorize(P)
ans = 1
for i in fac:
    ans *= i[0] ** (i[1] // N)
print(ans)

Measured memory_bytes: 3064
m500 = [35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0]
m1000 = [71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0]
category = ["AAA", "AA", "A", "B", "C", "D", "E", "NA"]
while True:
    try:t500, t1000 = list(map(float, input().split()))
    except:break
    for i in range(len(m500)):
        if t500 < m500[i] and t1000 < m1000[i]:print(category[i]);break


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

int main() {
	int n;
	cin >> n;
	string ans = "APPROVED";
	vector<int> a(n);

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

	for(int i=0; i<n; i++){
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				ans = "DENIED";
			}
		}
	}
	cout << ans << endl;
	return 0;

}

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

int main( )
{
    string s, t;
    cin >> s >> t;
    int i, c = 0;
    for (i = 0; i < 3; i++) {
        if (s[i] == t[i]) c++;
    }
    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 256
h,w = map(int, input().split())
ch, cw = map(int, input().split())
ch -= 1
cw -= 1
dh,dw = map(int, input().split())
dh -= 1
dw -= 1

def trans(s):
    res = []
    for i in s:
        if i == '.':
            res.append(-1)
        else:
            res.append(-2)
    return res

def move(x,y,dq,dq_next):
    for ix,iy in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
        if ix > h-1 or ix < 0 or iy > w-1 or iy < 0:
            continue
        if (m[ix][iy] == -1) or (m[ix][iy] > m[x][y]):
            m[ix][iy] = m[x][y]
            dq.append((ix, iy))
    for ix, iy in [(x-2, y-2), (x-2, y-1), (x-2, y), (x-2, y+1), (x-2, y+2),
                        (x-1, y-2), (x-1, y-1), (x-1, y+1), (x-1, y+2),
                        (x, y-2), (x, y+2),
                        (x+1, y-2), (x+1, y-1), (x+1, y+1), (x+1, y+2),
                        (x+2, y-2), (x+2, y-1), (x+2, y), (x+2, y+1), (x+2, y+2)]:
        if ix > h-1 or ix < 0 or iy > w-1 or iy < 0:
            continue
        if m[ix][iy] == -1:
            m[ix][iy] = m[x][y] + 1
            dq_next.append((ix, iy))
            
m = [trans(input()) for _ in range(h)]

from collections import deque

m[ch][cw] = 0

def main():
    dq = deque()
    dq_next = deque()
    dq.append((ch,cw))
    while True:
        while len(dq)>0:
            xx, yy = dq.popleft()
            if xx == dh and yy == dw:
                return m[xx][yy]
            move(xx, yy, dq, dq_next)
        if len(dq_next) > 0:
            dq = dq_next.copy()
            dq_next = deque()
        else:
            return -1
          
print(main())

Measured memory_bytes: 96756
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
const int N=100005;
int a[N],t[N];
char s[N];
bool check(int pp,int qq,int n)
{
    int i;
    t[1]=pp,t[2]=qq;
    for (i=2;i<=n-1;i++) t[i+1]=t[i-1]^t[i]^a[i];
    if (t[2]==t[n]^t[1]^a[1]&&t[1]==t[n-1]^t[n]^a[n]) return 1;
     else return 0;
}
void Print(int n)
{
    for (int i=1;i<=n;i++) if (t[i]==0) printf("S"); else printf("W");
    puts("");
}
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,n;
    scanf("%d",&n);scanf("%s",s+1);
    for (i=1;i<=n;i++) if (s[i]=='o') a[i]=0; else a[i]=1;
    for (i=0;i<=1;i++)
     for (j=0;j<=1;j++)
      if (check(i,j,n)) {Print(n);return 0;}
    puts("-1");
    
    return 0;
}


Measured memory_bytes: 1280
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
cnt=0
x=0
d=[]
for i in range(n):
	if x==a[i]:
		cnt+=1
	else:
		x=a[i]
		cnt=0
	if cnt==1:
		d.append(a[i])
	if cnt==3:
		d.append(a[i])
	if len(d)==2:
		break
if len(d)<=1:
	print(0)
	exit()
print(d[0]*d[1])

Measured memory_bytes: 14244
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[MX];
int used[MX];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
     int k;
    cin >> k;
    fi(0, n) {
    	cin >> a[i];
    	--a[i];
    }
    int cur = 0;
    int done = 1;
    int cyc = 0;
    while (true) {
    	used[cur] = done;
    	cur = a[cur];
    	if (done == k) {
    		cout << cur + 1 << '\n';
    		return 0;
    	}
    	++done;
    	if (used[cur]) {
    		cyc = done - used[cur];
    		break; 
    	} 
    }
    dbg(done);
    dbg(cyc);
 	k -= done - 1;
 	k %= cyc;
    fi(0, k) {
    	cur = a[cur];
    }
    cout << cur + 1 << '\n';
}

Measured memory_bytes: 6736
#include<cstdio>
#include<cmath>
using ll = long long;
constexpr ll p=1e9+7;
//sqrt(1e9)==31622.77...
//dp[i][0][j]=長さiの正整数列で、i番目の数がjであるようなものの個数 (j<=sqrt(n))
//dp[i][1][j]=長さiの正整数列で、(i番目の数)*j<=n,(i番目の数)*(j+1)>nであるようなものの個数 (j<=sqrt(n))
//dp[i+1][0][j]=sum_{l<=j}dp[i][1][l]+sum_l dp[i][0][l]
//dp[i+1][1][j]=(sum_{l<=j}dp[i][0][l])*dp[1][1][j]
//累積和をとると更新を1個当たりO(1)でできる
ll dp11[31624];
ll dp[2][2][31624];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int sqrtn=static_cast<int>(std::sqrt(n));
    for(int j=1;j<=sqrtn;j++){
        dp[1][0][j]=1;
        dp[1][1][j]=n/j-n/(j+1);
    }
    //もしsqrtnがdp[1][1][sqrtn]でカウントされていたら、dp[1][0][sqrtn]ではカウントしない
    if(sqrtn*(sqrtn+1)>n)dp[1][1][sqrtn]=0;
    for(int j=1;j<=sqrtn;j++)dp11[j]=dp[1][1][j];
    for(int i=1;i<k;i++){
        ll psum=0;
        for(int j=1;j<=sqrtn;j++){
            psum+=dp[i%2][0][j];
            psum%=p;
            dp[(i+1)%2][1][j]=psum*dp11[j]%p;
            //printf("%lld ",dp[i+1][1][j]);
        }
        //printf(": ");
        for(int j=sqrtn;j>=1;j--){
            psum+=dp[i%2][1][j];
            psum%=p;
            dp[(i+1)%2][0][j]=psum;
            //printf("%lld ",dp[i+1][0][j]);
        }
        //printf("\n");
    }
    ll ans=0;
    for(int j=1;j<=sqrtn;j++){
        ans+=dp[k%2][0][j]+dp[k%2][1][j];
        ans%=p;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
	static class Path {
		int idx;
		double dd;
		public Path(int idx, double dd) {
			this.idx = idx;
			this.dd = dd;
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double xs = sc.nextDouble();
		double ys = sc.nextDouble();
		double xt = sc.nextDouble();
		double yt = sc.nextDouble();
		int N = sc.nextInt();

		int L = N+2;
		double[] x = new double[L];
		double[] y = new double[L];
		double[] r = new double[L];
		for(int i=0; i<N; i++) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
			r[i] = sc.nextDouble();
		}
		x[N] = xs;
		y[N] = ys;
		x[N+1] = xt;
		y[N+1] = yt;
		
		double[][] d = new double[L][L];
		for(int i=0; i<L; i++) {
			for(int j=0; j<L; j++) {
				d[i][j] = d[j][i] = Math.max(0, dis(x[i],y[i],x[j],y[j])-r[i]-r[j]);
			}
		}
		
		int s = N;
		int t = s+1;
		double[] minD = new double[L];
		Arrays.fill(minD, 1l<<40);
		
		PriorityQueue<Path> q = new PriorityQueue<Path>(new Comparator<Path>() {
			public int compare(Path p1, Path p2) {
				return Double.compare(p1.dd, p2.dd);
			}
		});
		
		q.add(new Path(s, 0));
		while(!q.isEmpty()) {
			Path cur = q.poll();
			if(cur.dd < minD[cur.idx]) {
				minD[cur.idx] = cur.dd;
				if(cur.idx==t)
					break;
				for(int i=0; i<L; i++)
					if(cur.dd + d[cur.idx][i] < minD[i])
						q.add(new Path(i, cur.dd + d[cur.idx][i]));
			}
		}
		
		System.out.println(minD[t]);
		sc.close();
	}
	
	static double dis(double x1, double y1, double x2, double y2) {
		return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	}
}


Measured memory_bytes: 50776
N=int(input())

def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


garr=0

def idontknow(P):
    global garr
    D=P
    garr=0
    for i in range(1,P+1):
        if D>=i:
            garr+=1
            D=D-i
        else:
            return garr


FFF=fact(N)


ans=0

for i in range(len(FFF)):
    idontknow(int(FFF[i][1]))
    ans+=garr

if N==1:
    print(0)
else:
    print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    int mx = 0;
    for (auto &el: arr) cin >> el, mx = max(mx, el);

    int res = 0;
    bool flag = true;
    for (auto el: arr) {
        if (flag && el == mx) flag = false;
        else res += el;
    }
    res += mx / 2;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll ans = 0;
  cin >> s;
  
  //vector<ll> a(n); 
  rep(i, 0, 4) {
    if(s[i] == '2') ans++;
  }
  
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 256
import math
dat = input()
dat = dat.split()
n = int(dat[0])
m = int(dat[1])
r = int(dat[2])
if r-m*n < 0:
    sum = 0
else:
    sum = math.factorial(r-m*n+n-1)//math.factorial(r-m*n)//math.factorial(n-1)
print(sum)


Measured memory_bytes: 5796
import math
#def main(S, b):
if __name__ == '__main__':
    n, m = map(int, input().split())

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

    s = sum(a)

    if (n - s < 0):
        print(-1)
    else:
        print(n - s)

    #print(n * 2 * pi)


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

using namespace std;

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

    long long m = 0;
    long long a = 0;
    long long r = 0;
    long long c = 0;
    long long h = 0;

    vector<string> S(N);
    for (long long i = 0; i < N; i++) {
        cin >> S.at(i);
        char s = S.at(i).at(0);
        switch (s) {
            case 'M':
            m++;
            break;
            case 'A':
            a++;
            break;
            case 'R':
            r++;
            break;
            case 'C':
            c++;
            break;
            case 'H':
            h++;
        }
    }

    long long  ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h
        + a * r * c + a * r * h + a * c * h
        + r * c * h;
    cout << ans << endl;

    


}


Measured memory_bytes: 6356
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//�G�X�g���l�X���
vector<ll> estora(vector<ll> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}

const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int x;
    scanf("%d", &x);
    if (x >= 30)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

using namespace std;

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

  int A,B; cin>>A>>B;
  if (A >= 1 and A <= 9 and B >= 1 and B <= 9) {
    cout << A*B << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
l=[0]*26
for d in range(D):
    x=[S[d][i]-sum([(d-l[j])*C[j] for j in range(26) if i!=j]) for i in range(26)]
    j=x.index(max(x))
    l[j]=d+1
    print(j+1)

Measured memory_bytes: 9512
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

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

int main()
{
    int a[5] = {}, m = 10, last = 5;
    FOR(i, 0, 5)
    {
        cin >> a[i];
        if (a[i] % 10 > 0 && a[i] % 10 < m)
        {
            last = i;
            m = a[i] % 10;
        }
    }
    int res = 0;
    FOR(i, 0, 5)
    {
        if (i == last)
            res += a[i];
        else
        {
            res += (a[i] % 10 != 0 ? a[i] / 10 + 1 : a[i] / 10) * 10;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
#define mt(A,B) memset(A,B,sizeof(A))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
//const double PI = acos(-1);
const int N=1e5+10;
//const int M=1e6+10;
const LL mod=1e9+7;
const int inf = 0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
const int MAXM=500010;
inline char nc()
{
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <class T>inline void read(T &x)
{
    char c = nc(), b = 1;
    for (; !(c >= '0' && c <= '9'); c = nc()) if (c == '-') b = -1;
    for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc());
    x *= b;
}
int a[3][N],dp[3][N];
void solve()
{
     int n;
     cin>>n;
     mt(dp,-inf);
     for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }
     }
     dp[1][1]=a[1][1];
     for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            if(i==1&&j==1)continue;
            if(i==1)dp[i][j]=dp[i][j-1]+a[i][j];
            else{
                if(j==1)dp[i][j]=dp[i-1][j]+a[i][j];
                else dp[i][j]=max(dp[i][j],max(dp[i-1][j]+a[i][j],dp[i][j-1]+a[i][j]));
            }
        }
     }
     cout<<dp[2][n]<<endl;
}
int main()
{
#ifdef Local
    freopen("data.h","r",stdin);
    //freopen("out1.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

#define UND_NODE -1

typedef struct {
//    int id;
    int firstChild;
    int nextSibling;
    int parent;
} BinaryNode;

//int nodeIndexFromId(BinaryNode nodes[], int length, int id) {
//    for (int i = 0; i < length; i++)
//        if(nodes[i].id == id)
//            return i;
//}

int nodeDepthFromId(BinaryNode nodes[], int length, int id) {
    int i = 0;
    while (nodes[id].parent != UND_NODE) {
        i++;
        id = nodes[id].parent;
    }
    return i;
}

void printArray(int array[], int length) {
    for (int i = 0; i < length; i++) {
        if (i) printf(", ");
        printf("%d", array[i]);
    }
}


int main(int argc, char** argv) {
    int nNodes, nChildren;
    scanf("%d", &nNodes);
    
    BinaryNode nodes[nNodes]; // Binary tree
    int i, j, parentNodeId, currentNodeId, incomingNodeId;
    
    for (i = 0; i < nNodes; i++)
        nodes[i].parent = nodes[i].firstChild = nodes[i].nextSibling = UND_NODE;
    
    for (i = 0; i < nNodes; i++) {
        scanf("%d", &(parentNodeId)); // id
        scanf("%d", &(nChildren)); // k, number of children

        for (j = 0; j < nChildren; j++) {
            scanf("%d", &(incomingNodeId));
            if (j == 0) {
//                printf("firstChild of %d will be %d", parentNodeId, incomingNodeId);
                nodes[parentNodeId].firstChild = incomingNodeId;
            }
            else {
//                printf("nextSibling of %d will be %d", currentNodeId, incomingNodeId);
                nodes[currentNodeId].nextSibling = incomingNodeId;
            }
            
            currentNodeId = incomingNodeId;
            
            nodes[incomingNodeId].parent = parentNodeId;
            
//            printf("parentNodeId: %d; currentNodeId: %d; incomingNodeId: %d\n", parentNodeId, currentNodeId, incomingNodeId);
//            printf("incoming;   node %d: parent = %d\n", incomingNodeId, nodes[incomingNodeId].parent);
//            printf("parentNode; node %d: parent = %d\n", parentNodeId, nodes[parentNodeId].parent);
        }
    }
    
    for (i = 0; i < nNodes; i++) {
        j = nodeDepthFromId(nodes, nNodes, i);
        
        printf("node %d: parent = %d, depth = %d, ", i, nodes[i].parent, j);
        
        // node types
        if (nodes[i].parent == UND_NODE)
            printf("root, ");
        else if (nodes[i].firstChild == UND_NODE)
            printf("leaf, ");
        else 
            printf("internal node, ");
        
        // children
        printf("[");
        if (nodes[i].firstChild != UND_NODE) {
            printf("%d", nodes[i].firstChild);
            j = nodes[i].firstChild;
            while (nodes[j].nextSibling != UND_NODE) {
                printf(", %d", j = nodes[j].nextSibling);
            }
        }
        printf("]\n");
    }
    

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 3028
#h = list(map(int, input().split()))
#r = int(input())
#n, d = map(int, input().split())

n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

sa = sorted(a)
sa.reverse()

m1 = sa[0]
m2 = sa[0]
for i in sa:
    if i != m1:
        m2 = i
        break

if a.count(m1) >= 2:
    for i in a:
        print(m1)
else:
    for i in a:
        if i == m1:
            print(m2)
        else:
            print(m1)



Measured memory_bytes: 14064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=a; i<=min(b, a+k-1); i++){
        cout << i << endl;
    }
    for(int i=max(b-k+1, a+k); i<=b; i++){
        cout << i << endl;
    }
    return 0;
}

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

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

	vector <int> v;
	int a,b,k;

	cin >> a >> b >> k;

	for(int i=1;i<=100;i++)
	{
		if(a%i==0 && b%i==0)
		{
			v.push_back(i);
		}
	}

	sort(v.rbegin(),v.rend());

	cout << v[k-1] << '\n';
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val S = input.next()
    val T = input.next()
    
    if (S.equals(T.substring(0, S.length))) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 36372
h,w=map(int,input().split())
li=[input() for i in range(h)]
black=0
for i in li:
  temp=i.count("#")
  black+=temp

zenbu="#"*w
li.insert(0,zenbu)
li.append(zenbu)

for i in range(h+2):
  li[i]="#"+li[i]
  li[i]+="#"

ys,xs=2,2
yg,xg=h+1,w+1
a=li

n=[(ys-1,xs-1)]
route={n[0]:0}
p=[[1,0],[0,1],[-1,0],[0,-1]]
count=1
while route.get((yg-1,xg-1),0)==0 and count != 10000:
    n2=[]
    for i in n:
        for j in p:
            np=(i[0]+j[0],i[1]+j[1])
            if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                n2.append(np)
                route[np]=count
    n=n2
    count+=1
if count==10000:
  print(-1)
else:
  print(h*w-black-count)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l, r;
	while (cin >> n >> l >> r && n) {
		vector<int> a(n);
		for (auto&& i : a) {
			cin >> i;
		}
		int ans = 0;
		bool found;
		for (int i = l; i <= r; i++) {
			found = false;
			for (int j = 0; j < n; j++) {
				if (i % a[j]) continue;
				found = true;
				if (j % 2 == 0) {
					ans++;
				}
				break;
			}
			if (!found) {
				ans += !(n % 2);
			}
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3184
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))




int main(){
    ll n,k;
    cin >>n>>k;

    if((n+1)/2>=k)cout <<"YES"<<endl;
    else cout <<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

  int x=N,y=0,z=0;
  if(N*10000 < Y){
    cout << "-1 -1 -1" << endl;
    return 0;
  }
  else{
      for(x = 0;x <= N;x++){
        for(y = 0;y <= N;y++){
          z = N - x- y;
          if(x*10000+y*5000+z*1000 == Y && z >= 0){
            cout << x << " " << y << " " << z << endl;
            return 0;
          }
        }
      }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s; cin >> s;
    int len = s.length();
    int c = 0;
    for(int i = 0; i < len-1; i++){
        if(s[i] != s[i+1]) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 512
def f_knapsack_for_all_subsets(MOD=998244353):
    N, S = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    # dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数
    dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
    dp[0][0] = 1  # インデックスの集合が空のとき、和は 0 の 1 通り
    for i, a in enumerate(A):
        for j in range(S + 1):
            # editorial でいうところの選択肢 2, 3 に相当するので、2 倍
            dp[i + 1][j] += 2 * dp[i][j]
            dp[i + 1][j] %= MOD
            if j + a <= S:  # 選択肢 1
                dp[i + 1][j + a] += dp[i][j]
                dp[i + 1][j + a] %= MOD
    return dp[N][S]

print(f_knapsack_for_all_subsets())

Measured memory_bytes: 147024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg = str(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) if (flg[i] ^ '0')
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] ^ '0') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

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

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto legendre = [&](ll n, ll p) -> ll {
        ll res = 0;
        for (ll i = p; i <= n; i *= p)
            res += n / i;

        return res;
    };

    ll ans = 1;
    for (ll p : sieve(n))
        (ans *= legendre(n, p) + 1) %= MOD;

    std::cout << ans << '\n';
}


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

int main(){
  long long int A=0,N,M;
  cin >> N >> M;
  if(2*N>=M){
    cout << M/2 << endl;
  }else{
    M-=(2*N);
    A+=N;
    cout << A+(M/4) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e5+5;

int n;
int h[MAX_N];
int dp[MAX_N];

int main()
{
	memset(dp,0x7F,sizeof(dp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	dp[1]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>

int parse(std::string const& s, size_t& i) {
  if (isdigit(s[i])) return s[i++]-'0';

  assert(s[i] == '[');
  ++i;
  char op = s[i++];
  int lhs = parse(s, i);
  int rhs = parse(s, i);
  assert(s[i] == ']');
  ++i;

  if (op == '+') return lhs | rhs;
  if (op == '*') return lhs & rhs;
  if (op == '^') return lhs ^ rhs;
  assert(false);
}

int testcase_ends() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  if (s == ".") return 1;

  char a, b, c, d;
  scanf(" %c%c%c%c", &a, &b, &c, &d);

  std::string t = s;
  for (auto& ti: t) {
    if (ti == 'a') ti = a;
    if (ti == 'b') ti = b;
    if (ti == 'c') ti = c;
    if (ti == 'd') ti = d;
  }

  size_t k = 0;
  int hash = parse(t, k);
  int res = 0;
  for (size_t i = 0; i < 10000; ++i) {
    std::string t = s;
    char abcd[4] = {};
    for (int j = 0, tmp = i; j < 4; ++j) {
      abcd[3-j] = '0' + (tmp % 10);
      tmp /= 10;
    }
    char a, b, c, d;
    a = abcd[0];
    b = abcd[1];
    c = abcd[2];
    d = abcd[3];
    for (auto& ti: t) {
      if (ti == 'a') ti = a;
      if (ti == 'b') ti = b;
      if (ti == 'c') ti = c;
      if (ti == 'd') ti = d;
    }

    size_t k = 0;
    int hash0 = parse(t, k);
    if (hash0 == hash) ++res;
  }

  printf("%d %d\n", hash, res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2844
#include<iostream>
#include<stdio.h>
using namespace std;

int main () {
    int a,b;
    char op;
    while (true) {
        cin >> a >> op >> b;
        if (op == '+') {
            cout << a+b << endl;
        }
        else if (op == '-') {
            cout << a-b << endl;
        }
        else if (op == '*') {
            cout << a*b << endl;
        }
        else if (op == '/') {
            cout << a/b << endl;
        }
        else if (op == '?') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;

int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

int main()
{
  int a,b;
  cin>>a>>b;
  int c[3];
  c[0]=a+b;
  c[1]=a*b;
  c[2]=a-b;
  sort(c,c+3);
  cout<<c[2];
  return 0;
}

Measured memory_bytes: 256
MAX = 100003 #階乗のmodを求めたい中で最大のもの
MOD = 10**9+7

fac = [0]*MAX   #階乗のmod
inv = [0]*MAX    #その数の逆元
finv = [0]*MAX   #階乗の逆元

def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = (fac[i-1] * i) % MOD
        inv[i] = MOD-(inv[MOD%i] * (MOD//i))%MOD
        finv[i] = (finv[i-1]*inv[i]) %MOD
        
    
def COM(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return (fac[n] * (finv[k]*finv[n-k]))%MOD

#pが素数でないと使えない
COMinit()    
n,m = map(int,input().split())
if abs(n-m) > 1:
  print(0)
elif abs(n-m) == 1:
  print(fac[n]*fac[m] %MOD)
else:
  print(2*fac[n]*fac[m] %MOD)

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

const int INF = 1000000;

const int max_v = 100;
int d[max_v][max_v];
int V;

void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

struct edge {int from, to, cost;};

int main() {
    int n, m;
    cin >> n >> m;
    V = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    vector<edge> e(0);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        e.push_back(edge{a, b, c});
    }

    warshall_floyd();
    
    vector<bool> used(m);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = 0; k < m; k++) {
                if ((d[i][j] == d[i][e.at(k).from] + e.at(k).cost + d[e.at(k).to][j]) || (d[i][j] == d[i][e.at(k).to] + e.at(k).cost + d[e.at(k).from][j])) used.at(k) = true;
            }
        }
    }
    
    int cnt = 0;
    for (bool b: used) {
        if (!b) cnt++;
    }
        
    cout << cnt << endl;
}   

Measured memory_bytes: 256
/*
AizuOnline A0220

*/
#include <stdio.h>
#include <float.h>
#include <math.h>
#define MAXVAL (255+0.5+0.25+0.125+0.0625)
char buf[20];
int bufptr;
int  value;
double v;


main()
{
  int d;
  while(EOF != scanf("%lf",&v) && v>0.0)
    {
      bufptr=19;
      buf[bufptr]='\0';
      if(floor(v*16) != v*16 || v > MAXVAL)
	{
	  printf("NA\n");
	  continue;
	}
      if(v == 0.0)
	{
	  printf("0.0\n");
	  continue;
	}
      value = v*16;
      while(value > 0)
	{
	  d = value & 1;
	  bufptr--;
	  if(bufptr==14)bufptr--;
	  buf[bufptr]='0'+d;
	  value >>= 1;	  
	}
      buf[14]='.';

      switch(bufptr){
      case 18:
	buf[17]='0';
      case 17:
	buf[16]='0';
      case 16:
	buf[15]='0';
      case 15:
	buf[13]='0';buf[14]='.';bufptr=13;
      }
      for(bufptr--;bufptr >5;bufptr--)
       buf[bufptr]='0';
      bufptr++;

      printf("%s\n",buf+bufptr);
      //printf("(%d)",bufptr);
    }

return(0);
}

Measured memory_bytes: 616
N=int(input())
A=[[0,0,0]]
for i in range(N):
  A.append(list(map(int,input().split())))

flag=True

for i in range(0,N):
  dt=A[i+1][0]-A[i][0]
  dx=abs(A[i+1][1]-A[i][1])
  dy=abs(A[i+1][2]-A[i][2])
  if not (dx+dy<=dt and (dx+dy-dt)%2==0):
    flag=False
    break
    
print('Yes' if flag else 'No')  

Measured memory_bytes: 27380
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <ctime>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int unt;
typedef double db;
typedef pair <int, int> pii;
typedef vector <int> vi;

#define Fi first
#define Se second
#define pb push_back
#define mp make_pair
#define rep(x, a, b) for(int x = (a); x <= (b); ++ x)
#define per(x, a, b) for(int x = (a); x >= (b); -- x)
#define rop(x, a, b) for(int x = (a); x < (b); ++ x)
#define por(x, a, b) for(int x = (a); x > (b); -- x)
#define forE(x, a) for(int x = head[a]; x; x = nxt[x])

#ifdef DEBUG
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define debug(x)
#endif

const db eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const LL MINF = 0x7f7f7f7f7f7f7f7fll;

int main() {
	int n; scanf("%d", &n);
	rep(i, 1, 9) rep(j, 1, 9) {
		if(i * j == n) return 0 * puts("Yes");
	}
	puts("No");
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < 6){
			System.out.print(0);
		}else if(a < 13){
			System.out.print(b/2);
		}else{
			System.out.print(b);
		}
	}
}


Measured memory_bytes: 21844
// AtCoder Beginner Contest 113 - Problem A: Discount Fare (https://beta.atcoder.jp/contests/abc113/tasks/abc113_a)
#include <bits/stdc++.h>

using namespace std;

void solve(int X, int Y)
{
    auto ans = X + Y/2;

    cout << ans << endl;
}

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

    int X, Y;
    cin >> X >> Y;

    solve(X, Y);

    return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<char,int> t;
int main(){
    string s;
    cin>>s;
    rep(i,s.size()) ++t[s[i]];
    for(auto it:t){
        if(it.second%2==1){
            cout<<"No"<<endl;return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define inf int(1e9)
#define half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

string s;

void solve() {
    ll n_w = 0, ans = 0;
    repr(i, s.length()) {
        if (s[i] == 'W') n_w++;
        if (s[i] == 'B') ans += n_w;
    }
    cout << ans << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int *arr=new int[n+1];
    memset(arr,0,sizeof(int)*(n+1));
    for(int i=1; i<=k; ++i)
    {
        int d;
        cin>>d;
        for(int i=1; i<=d; ++i)
        {
            int x;
            cin>>x;
            ++arr[x];
        }
    }
    int icount=0;
    for(int i=1; i<=n; ++i)
    {
        if(arr[i]==0)
            ++icount;
    }
    cout<<icount<<endl;
    return 0;
}


Measured memory_bytes: 3604
a = int(input())
b = int(input())
c = int(input())
x = int(input())
t = 0

for i in range(a+1):
    if 500*i>x:break
    for j in range(b+1):
        if 100*j>x:break
        for k in range(c+1):
            if 50*k>x:break
            if x - 500*i - 100*j - 50*k == 0:
                t += 1

print(t)

Measured memory_bytes: 3060