akhauriyash/Code-Regression huggingface dataset:
s = input()

s1 = set(s[::2])
s2 = set(s[1::2])

print("Yes" if ({'R', 'U', 'D'} | s1 == {'R', 'U', 'D'} and {'D', 'L', 'U'} | s2 == {'D', 'L', 'U'}) else "No")


Measured memory_bytes: 2940
#include<stdio.h>


int selectionSort(int A[], int N) {
  int i, j, t, sw=0, minj;
  for (i=0 ; i<N; i++) {
    minj = i;
    for (j=i; j<N; j++) {
      if (A[j]<A[minj]) minj=j;
    }
    t=A[i]; A[i]=A[minj]; A[minj]=t;
    if (i!=minj) sw++;
  }

  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);
  for (i=0; i<N; i++) scanf("%d", &A[i]);

  sw=selectionSort(A, N);

  for (i=0; i<N; i++) {
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
string s;
int n, mid;

bool pand(string str){
	if(str.length()%2==0)	mid = str.length()/2;
	else	mid = (str.length()-1)/2;
	
	for(int i=0; i<mid; i++){
		if(str[i]!=str[str.length()-(i+1)])	return false;
	}
	return true;
}

int main() {
	cin>>s;
	int m = (s.length()-1)/2;
	string tmp1 = s.substr(0,m);
	string tmp2 = s.substr(m+1,s.length());
	if(pand(s)&&pand(tmp1)&&pand(tmp2))	cout<<"Yes";
	else	cout<<"No";

	return 0;
}

Measured memory_bytes: 256
data = []
for j in range(3):
  data.extend([int (i) for i in input().split()])

bingo_dic = {}
for i, d in enumerate(data):
  bingo_dic[d] = i
  
N = int(input())

bingo = [0,0,0,0,0,0,0,0,0]
for _ in range(N):
  i = int(input())
  if i in bingo_dic.keys():
    bingo[bingo_dic[i]] = 1
    
if bingo[0] + bingo[1] + bingo[2] == 3:
  print('Yes')
  exit()
  
if bingo[3] + bingo[4] + bingo[5] == 3:
  print('Yes')
  exit()
  
if bingo[6] + bingo[7] + bingo[8] == 3:
  print('Yes')
  exit()
  
if bingo[0] + bingo[3] + bingo[6] == 3:
  print('Yes')
  exit()

if bingo[1] + bingo[4] + bingo[7] == 3:
  print('Yes')
  exit()
  
if bingo[2] + bingo[5] + bingo[8] == 3:
  print('Yes')
  exit()
  
if bingo[0] + bingo[4] + bingo[8] == 3:
  print('Yes')
  exit()

if bingo[2] + bingo[4] + bingo[6] == 3:
  print('Yes')
  exit()

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll taka = a, aoki = c;
    ll t = 0;
    while(taka > 0 && aoki > 0) {
        if(t%2 == 0) {
            aoki -= b;
        }
        else {
            taka -= d;
        }
        t++;
    }

    if(taka <= 0) {
        out("No");
    }
    else {
        out("Yes");
    }

    re0;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int x,n;
    cin>>x>>n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        sum+=a;
    }
    if(x>=sum)
        cout<<x-sum<<endl;
    else
        cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N;
int a[20000];

int main() {
  cin >> N;
  if (N == 3) {
    cout << "2 5 63" << endl;
  } else {
    a[0] = 2;
    a[1] = 4;
    a[2] = 3;
    a[3] = 9;
    if (N <= 10003) {
      if (N % 2 == 0) {
        for (int k = 4; k < N; k += 2) {
          a[k] = (k - 2) * 3 + 2;
          a[k + 1] = a[k] + 2;
        }
      } else {
        a[4] = 6;
        for (int k = 5; k < N; k += 2) {
          a[k] = (k - 3) * 3 + 2;
          a[k + 1] = a[k] + 2;
        }
      }
    } else if (N <= 15001) {
      if (N % 2 == 0) {
        for (int i = 4; i < 10002; i += 2) {
          a[i] = (i - 2) * 3 + 2;
          a[i + 1] = a[i] + 2;
        }
        for (int k = 10002; k < N; k++) {
          if (k == 10002) {
            a[k] = 15;
          } else {
            a[k] = a[k - 1] + 6;
          }
        }
      } else {
        for (int i = 4; i < 10002; i += 2) {
          a[i] = (i - 2) * 3 + 2;
          a[i + 1] = a[i] + 2;
        }
        for (int k = 10002; k < N - 1; k++) {
          if (k == 10002) {
            a[k] = 15;
          } else {
            a[k] = a[k - 1] + 6;
          }
        }
        a[N - 1] = 6;
      }
    } else {
      for (int i = 4; i < 10002; i += 2) {
        a[i] = (i - 2) * 3 + 2;
        a[i + 1] = a[i] + 2;
      }
      for (int k = 10002; k < 15000; k++) {
        if (k == 10002) {
          a[k] = 15;
        } else {
          a[k] = a[k - 1] + 6;
        }
      }
      for (int i = 15000; i < N; i++) {
        if (i == 15000) {
          a[i] = 6;
        } else {
          a[i] = a[i - 1] + 6;
        }
      }
    }
    for (int i = 0; i < N - 1; i++) {
      cout << a[i] << " ";
    }
    cout << a[N - 1] << endl;
  }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,b,h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	printf("%.201f\n",sqrt(a*a+b*b-2*a*b*cos(2*M_PI*fabs(60*h-11*m)/720)));
	return 0;
}

Measured memory_bytes: 2604
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


int n;
int a[200010];
VI v;

void solve() {
  cin >> n;
  REP(i, n) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(ALL(v));
  int mx = v.back();
  int mx2 = v[SZ(v)-2];
  REP(i, n) {
    if (a[i] == mx) {
      cout << mx2 << endl;
    } else{
      cout << mx << endl;
    }
  }
}

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


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
ll n;
ll w;
ll weight[110], value[110]; 
ll dp[110][100100];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> w;
    for (ll i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    
    for (ll i = 0; i < n; i++) {
        for (ll sum_w=0; sum_w <= w; sum_w++) {
            if (sum_w - weight[i] >=0)
                chmax(dp[i+1][sum_w], dp[i][sum_w-weight[i]] + value[i]);
            
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][w] << endl;
    
    return 0;
}


Measured memory_bytes: 79360
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 10010;
const int MAXM = 1000010;
const int MAXK = 16;
const int MAXQ = 200010;

int nt[MAXM], a[MAXN], n, mu[MAXM];

void sieveBase(int n) {
    FOR(i,2,n) {
        if (nt[i] == 0) {
            nt[i] = i;
            for (ll j = (ll) i * i; j <= n; j += i) nt[j] = i;
        }
    }
}

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

ll inv(int u) {
    return binPowMod(u, MODBASE-2, MODBASE);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    sieveBase(1000000);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) {
        int p = a[i];
        vector<int> b;
        while (p > 1) {
            int x = nt[p];
            while (p % x == 0) {
                p /= x;
                b.emplace_back(x);
            }
        }
        sort(ALL(b));
        int cnt = 1;
        FOR(j,1,SZ(b)-1)
            if (b[j] == b[j-1]) cnt++;
            else {
                int u = b[j-1];
                mu[u] = max(mu[u], cnt);
                cnt = 1;
            }
        if (SZ(b)) {
            int u = b[SZ(b)-1];
            mu[u] = max(mu[u], cnt);
        }
    }

    ll lcm = 1;
    FOR(i,1,1000000)
        if (mu[i]) lcm = lcm * binPowMod(i, mu[i], MODBASE) % MODBASE;

    ll res = 0;
    FOR(i,1,n) {
        ll Bi = lcm * inv(a[i]) % MODBASE;
        res = (res + Bi) % MODBASE;
    }


    cout << res;
    return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
int main(void){
    int H,W;
    while(1){
        scanf("%d %d" , &H , &W);
        if(H == 0 && W == 0){break;}
        for(int i = 1 ; i <= H ; i ++){
            for(int j = 1 ; j <= W ; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    
    }
    
    return 0;
}


Measured memory_bytes: 2072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,k,s=0;
	cin>>n>>k;
	while(n!=0)
	{
		n/=k;
		s++;
	}
	cout<<s;
}

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

int h,w,n,c[1000][1000];
int dp[1001][1001];
int d[1000][1000];

int main(){
	while(scanf("%d%d%d",&h,&w,&n),h){
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) scanf("%d",&c[i][j]);
		for(int i=0;i<=1000;i++) for(int j=0;j<=1000;j++) dp[i][j]=0;
		dp[1][1]=n-1;
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
			if(i!=1){
				if(c[i-2][j-1]==0) dp[i][j]+=(dp[i-1][j]+1)/2;
				else dp[i][j]+=dp[i-1][j]/2;
			}
			if(j!=1){
				if(c[i-1][j-2]==1) dp[i][j]+=(dp[i][j-1]+1)/2;
				else dp[i][j]+=dp[i][j-1]/2;
			}
		}
		for(int i=0;i<h;i++) for(int j=0;j<w;j++)
			d[i][j]=(c[i][j]+dp[i+1][j+1])%2;
		int i=1,j=1;
		while(i<=h&&j<=w){
			if(d[i-1][j-1]) j++;
			else i++;
		}
		printf("%d %d\n",i,j);
	}
}

Measured memory_bytes: 12912
n=int(input())
A=list(map(int,input().split()))
B=[]
c1=0
c2=0
for a in A:
    if a%2==0:
        B.append(a//2)
        c1+=1
for b in B:
    if b%2==0:
        c1-=1
        c2+=1
if c1!=0 or c2!=0:
    if c1==0:
        if (n-1)-2*c2<=0:
            print('Yes')
            exit()
    else:
        if n-c1-2*c2<=0:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 14252
struct DFS {
    n: usize,
    g: Vec<Vec<usize>>,
    dp: Vec<Vec<usize>>,
}

impl DFS {
    fn new(n: usize) -> DFS {
        DFS {
            n,
            g: vec![Vec::new(); n],
            dp: vec![Vec::new(); n],
        }
    }

    fn add_edge(&mut self, from: usize, to: usize) {
        self.g[from].push(to);
        self.dp[from].push(to);
    }

    fn search(&mut self, par: usize, from: usize) -> usize {
        let mut sum = 0;
        let mut par_i = !0;
        for (i, &to) in self.g[from].clone().iter().enumerate() {
            if to == par {
                par_i = i;
                continue;
            }
            self.dp[from][i] = self.search(from, to);
            sum += self.dp[from][i];
        }
        if par_i != !0 {
            self.dp[from][par_i] = self.n - (sum + 1);
        }
        sum + 1
    }
}

fn main() {
    const MOD: usize = 1_000_000_007;

    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut dfs = DFS::new(n);
    for _ in 0..(n - 1) {
        let (a, b) = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse::<usize>().unwrap() - 1,
                iter.next().unwrap().parse::<usize>().unwrap() - 1,
            )
        };

        dfs.add_edge(a, b);
        dfs.add_edge(b, a);
    }
    dfs.search(!0, 0);

    let pow = |mut a, mut n| {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 {
                res = res * a % MOD;
            }
            a = a * a % MOD;
            n >>= 1;
        }
        res
    };

    let mut ans = 0;
    for i in 0..n {
        let mut res = 1;
        res = (res + MOD - pow(pow(2, n - 1), MOD - 2)) % MOD;
        let mut sum = 0;
        for &x in dfs.dp[i].iter() {
            let p = pow(pow(2, n - 1 - x), MOD - 2);
            let q = (1 + MOD - pow(pow(2, x), MOD - 2)) % MOD;
            sum = (sum + (p * q % MOD)) % MOD;
        }
        res = (res + MOD - sum) % MOD;
        ans = (ans + res * pow(2, MOD - 2)) % MOD;
    }
    println!("{}", ans);
}

Measured memory_bytes: 48960
while 1:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        for i in xrange(3, -1, -1):
            if a[i] == b[i]:
                del a[i]
                del b[i]
        print str(4 - len(a)) + " " + str(len(set(a) & set(b)))
    except:
        break

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

int main()
{
    int w,h,n;
    cin >> w >> h >> n;
    int x,y,a,flag[w][h] = {},ans = 0;
    for(int z = 0; z < n; z++){
        cin >> x >> y >> a;
        if(a == 1){
            for(int i = 0; i < x; i++)
                for(int j = 0; j < h; j++) flag[i][j] = 1;
        }else if(a == 2){
            for(int i = x; i < w; i++)
                for(int j = 0; j < h; j++) flag[i][j] = 1;
        }else if(a == 3){
            for(int i = 0; i < w; i++)
                for(int j = 0; j < y; j++) flag[i][j] = 1;
        }else{
            for(int i = 0; i < w; i++)
                for(int j = y; j < h; j++) flag[i][j] = 1;
        }
    }

    for(int i = 0; i < w; i++)
        for(int j = 0; j < h; j++) if(flag[i][j] == 0) ans++;

    cout << ans << endl;
    
    return 0;
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[]X = new int[N];
		
		for (int i=0; i<N; i++){
			X[i] = sc.nextInt();
		}
		Arrays.sort(X);
		int min = X[0];
		int max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
}

Measured memory_bytes: 21716
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

int n, m;

int oj[nax];

int fin(int v)
{
	if (v!=oj[v])
		oj[v]=fin(oj[v]);
	return oj[v];
}

void uni(int v, int u)
{
	oj[fin(v)]=fin(u);
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=2*n; i++)
		oj[i]=i;
	for (int i=1; i<=n; i++)
	{
		int a;
		scanf("%d", &a);
		uni(i, a+n);
	}
	for (int i=1; i<=m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		uni(a, b);
	}
	int wyn=0;
	for (int i=1; i<=n; i++)
		wyn+=(fin(i)==fin(i+n));
	printf("%d\n", wyn);
	return 0;
}


Measured memory_bytes: 1024
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 StreamReader sr;

        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 NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Sarray();
            var mask = (long)Pow(2, 40);
            var X = 0L;
            while (mask != 0)
            {
                var cnt1 = Ai.Count(a => 0 != (a & mask));
                if (cnt1 < N - cnt1 && X + mask <= K)//0bitの方が多ければbitを立てる
                    X += mask;
                mask >>= 1;
            }
            var ans = Ai.Sum(a => a ^ X);
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 31324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll a,b,x;
    cin>>a>>b>>x;
    ll ans=b/x;
    if(a==0) ans++;
    if(a!=0) ans-=(a-1)/x;

    cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
const int MAX_N = 16;
const int MAX_M = 1 << 16;
long long sum[MAX_M], f[MAX_M];
int a[MAX_N][MAX_N];

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) std::cin >> a[i][j];
  const int max = 1 << n;
  for (int s = 0; s < max; ++s) {
    for (int i = 0; i < n && (1 << i) <= s; ++i) {
      if (s >> i & 1) {
        for (int j = i + 1; j < n && (1 < j) <= s; ++j)
          if (s >> j & 1) sum[s] += a[i][j];
      }
    }
  }
  for (int s = 0; s < max; ++s)
    for (int j = s; j; j = (j - 1) & s)
      f[s] = std::max(f[s], f[s - j] + sum[j]);
  std::cout << f[max - 1];
  return 0;
}

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


int main(){
  int64_t N,D;
  int64_t X,Y;
  cin>>N>>D;
  int64_t D2=D*D;
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>X>>Y;
    if( (X*X+Y*Y) <= D2){
      sum++;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int a = stdin.nextInt();
	int b = stdin.nextInt();
	int c = stdin.nextInt();
	if(a<b && b<c){
	    System.out.println("Yes");
	}
	else{
	    System.out.println("No");
	}
    }
}

	
	

Measured memory_bytes: 26024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=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{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int n;
ll d;

ll dist(int x, int y){
    return (ll)pow(x,2)+(ll)pow(y,2);
}

int main(){
    cin >> n>>d;
    d=pow(d,2);
    int x,y;
    int ans = 0;
    vector<vector<int>> p(n,vector<int>(2));
    rep(i,n){
        cin >> x >> y;
        if(dist(x,y)<=d)ans++;
    }
    cout << ans << endl;
    return 0;

}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 10;
using namespace std;

int main() {
    IO;
    int n, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n / i; j++) {
            if (i * j < n) cnt++;
        }
    }
    cout << cnt;


}

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

using namespace std;
using ll = long long;

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

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

  // dp[i][j] := 区間[i, j)に対して双方最善を尽くした時のX-Yの値
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));
  for (int i = 0; i <= n; i++)
    dp[i][i] = 0;

  for (int len = 1; len <= n; len++) {
    for (int i = 0; i + len <= n; i++) {
      int j = i + len;

      // 先手
      if ((n - len) % 2 == 0) {
        dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
      } else {
        dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
      }
    }
  }

  cout << dp[0][n] << endl;

  return 0;
}


Measured memory_bytes: 73608
<?php
 
fscanf(STDIN, '%d', $n);
 
$arr = array();
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, '%s %s', $cmd, $str);
    if ($cmd == 'insert') {
        $arr[$str] = 1;
    } else {
        if (isset($arr[$str])) {
            echo 'yes', PHP_EOL;
        } else {
            echo 'no', PHP_EOL;
        }
    }
}

Measured memory_bytes: 50924
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int S,h,m,s,a,b,c,d;
cin>>S;
a=S/3600;
d=S%3600;
b=d/60;
c=d%60;
h=a;
m=b;
s=c;
cout<<h<<":"<<m<<":"<<s<<endl;
         return 0;
      }

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) int((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int tc=1;
	// cin>>tc;
	fo(q, tc)
	{
		ll n, ans=0;
		cin>>n;
		vll a(n);
		fo(i, n) cin>>a[i];
		ll m=0;
		fo(i, n){
			ans+=max(ll(0), m-a[i]);
			m=max(m, a[i]);
		}
		on(ans);
	}
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int selection_sort(vector<int> &a) {
	int n = a.size();
	int changes = 0;

	vector<int>::iterator it, min_it;
	for (it = a.begin(); it != a.end(); it++) {
		min_it = min_element(it, a.end());
		if (*it > *min_it) {
			swap(*it, *min_it);
			changes++;
		}
	}

	return changes;
}

int main() {
	int n;

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

	int changes = selection_sort(a);
	for (int i = 0; i < n; i++) {
		printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
	}
	printf("%d\n", changes);


	return 0;
}

Measured memory_bytes: 1172
#include <iostream>

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

const int MAX_SIZE = 1 << 24;
int dict[MAX_SIZE];

int convert(std::string str) {
  int l = str.length();
  int sum = -1;
  int mult = 1;
  rep(i, l) {
    char c = str[l - 1 - i];
    if (c == 'A') {
      sum += mult;
    } else if (c == 'C') {
      sum += 2 * mult;
    } else if (c == 'G') {
      sum += 3 * mult;
    } else {
      sum += 4 * mult;
    }

    mult *= 4;
  }

  return sum;
}

void insert(std::string str) {
  int idx = convert(str);
  // std::cout << str << ", " << idx << '\n';
  dict[idx] = 1;
}

void find(std::string str) {
  int idx = convert(str);
  if (dict[idx] == 1)
    std::cout << "yes" << '\n';
  else
    std::cout << "no" << '\n';
}

int main() {
  int n;
  std::cin >> n;
  std::string com, str;

  rep(i, n) {
    std::cin >> com >> str;
    if (com == "insert") {
      insert(str);
    } else {
      find(str);
    }
  }
  return 0;
}


Measured memory_bytes: 8620
a=raw_input().split(',')
b=[]
c=[]
for i in range(len(a)):
    for j in range(len(a[i])):
        if a[i][j].isalpha():
            if a[i][j].islower():
                b.append(a[i][j].upper())
            else:
                b.append(a[i][j].lower())
        else:
            b.append(a[i][j])
    c.append(''.join(b))
    b=[]
print(','.join(c))

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

const int maxN = 2010;
int costW[maxN + maxN][maxN];
int costB[maxN + maxN][maxN];
int dp[maxN][maxN];
char col[maxN + maxN];
int val[maxN + maxN];
int white[maxN];
int black[maxN];
int n;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n; int m = n + n;
	for (int i = 1; i <= m; i++) {
		cin >> col[i] >> val[i];
		if (col[i] == 'W') white[val[i]] = i;
		if (col[i] == 'B') black[val[i]] = i;
	}
	for (int i = 1; i <= m; i++) 
		for (int j = 0; j <= n; j++) {
			costW[i][j] = costW[i - 1][j];
			costB[i][j] = costB[i - 1][j];
			if (val[i - 1] > j and col[i - 1] == 'W') costW[i][j]++;
			if (val[i - 1] > j and col[i - 1] == 'B') costB[i][j]++;
			//cout << "i = " << i << " j = " << j << " " << costW[i][j] << " " << costB[i][j] << endl;
		}
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++) {
			if (i == 0 and j == 0) continue;
			dp[i][j] = INT_MAX;
			if (i != 0) {
				int pow = costW[white[i]][i - 1] + costB[white[i]][j];
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + pow);
			}
			if (j != 0) {
				int pow = costW[black[j]][i] + costB[black[j]][j - 1];
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + pow);
			}
		}
	cout << dp[n][n] << endl;
	return 0;
}

Measured memory_bytes: 79104
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long A, long B, long C, long[] l) {
    long dfs(long[] forA, long[] forB, long[] forC, long[] bamboos) {
        if (bamboos.length > 0)
            return min(
                dfs(forA, forB, forC, bamboos[1 .. $]),
                dfs(forA ~ bamboos[0], forB, forC, bamboos[1 .. $]),
                dfs(forA, forB ~ bamboos[0], forC, bamboos[1 .. $]),
                dfs(forA, forB, forC ~ bamboos[0], bamboos[1 .. $]));
        
        if (forA.length <= 0 || forB.length <= 0 || forC.length <= 0)
            return long.max;

        return
            abs(forA.sum - A) + (forA.length - 1) * 10 +
            abs(forB.sum - B) + (forB.length - 1) * 10 +
            abs(forC.sum - C) + (forC.length - 1) * 10;
    }

    return dfs([], [], [], l);
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long[] l = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        l[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A, B, C, l);
    else
        solve(N, A, B, C, l).writeln;
}


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){


    int n, t_score, h_score;
    t_score = 0;
    h_score = 0;
    cin >> n;
    vector<string> taro(n);
    vector<string> hana(n);

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

    for(int i=0; i<n; i++){
        string t = taro[i];
        string h = hana[i];
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        transform(h.begin(), h.end(), h.begin(), ::tolower);
        int len = max(t.size(), h.size());
        if(t==h){
            t_score += 1;
            h_score += 1;
        }else{
            for(int j=0; j<len; j++){
                if(int(t[j]) < int(h[j])){
                    h_score += 3;
                    break;
                }else if(int(t[j]) > int(h[j])){
                    t_score += 3;
                    break;
                }
            }
        }

    }

    cout << t_score << " " << h_score << endl;


    return 0;
}



Measured memory_bytes: 3312
A = [list(map(int, input().split(' '))) for  _ in range(3)]
N = int(input())
B = set([int(input()) for _ in range(N)])

X = []
X += [set(A[i]) for i in range(3)]
X += [set([A[j][i] for j in range(3)]) for i in range(3)]
X += [set([A[0][2], A[1][1], A[2][0]]), set([A[2][2], A[1][1], A[0][0]])]

for x in X:
    if x <= B:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 3064
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    for i in range(N):
        if A[i]%2==0:
            if not(A[i]%3==0 or A[i]%5==0):
                print("DENIED")
                exit()
    print("APPROVED")
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 62016
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe


type Dice = [([String], [String])]

makeDice :: [String] -> Dice
makeDice ls = map f di
  where
    f (xs, ys) = (map (ls' !!) xs, map (ls' !!) ys)
    ls' = "_" : ls
    di = [([1, 6], [5, 3, 2, 4]),
          ([2, 5], [1, 3, 6, 4]),
          ([3, 4], [1, 5, 6, 2]),
          ([4, 3], [1, 2, 6, 5]),
          ([5, 2], [1, 4, 6, 3]),
          ([6, 1], [2, 3, 5, 4])]

makeRotation :: [a] -> [[a]]
makeRotation xs = take 4 $ map (take 4) $ tails (cycle xs)

check :: Dice -> Dice -> Bool
check ds1 ds2
  | null ys       = True
  | otherwise = all (check' ds1) $ take 2 ys
  where
    ys = [x | x@([a, b], _) <- ds2, a /= b]
    check' ds1 (tb, ds)
      | zs == Nothing = False
      | otherwise = elem ds $ makeRotation $ fromJust zs
      where zs = lookup tb ds1


main :: IO ()
main = do
  n <- readLn
  ds <- map (makeDice . words) <$> replicateM n getLine
  let ans = nubBy check ds
  putStrLn $ if (length ans == n) then "Yes" else "No"



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

using namespace std;

using ll = long long;
using ld = long double;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, b = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'R')
		{
			r++;
		}
		else
		{
			b++;
		}
	}
	if (r > b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

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

    long long ans = 0;
    long long Rmax = N-1;
    for (long long i = 0; i < N; i++)
    {
        if (c[i] == 'W')
        {
            for (long long j = Rmax; j >= i; j--)
            {
                if (c[j] == 'R')
                {
                    Rmax = j - 1;
                    ans++;
                    break;
                }
                if (j == i)
                {
                    cout << ans << endl;
                    exit(0);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3800
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;

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

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

    sort(a, a+n);

    int res = 0;
    for (int j = 0; j < k; j++) {
        res += a[j];
    }

    cout << res << endl;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	int n;
	while(true)
	{
		cin >> n;
		if(n==0)break;
		vector<int> a(n);
		long long sum=0;
		for(int i=0;i<n;i++)
		{
			cin >> a[i];
			sum+=a[i];
		}
		double ave=sum/n;

		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]<=ave)
				ans++;
		}
		cout << ans << endl;
	}




}



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


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n, d; std::cin >> n >> d;
    double x[n][d];
    for(int i=0; i<n; i++)
        for(int j=0; j<d; j++)
            std::cin >> x[i][j];
    
    int cnt = 0;
    
    for(int j=0; j<n; j++)
    {
        for(int k=j+1; k<n; k++)
        {
            int len = 0;
            for(int i=0; i<d; i++)
            {
                int l1 = abs(x[k][i] - x[j][i]);
                len += l1 * l1;
            }

            for(int i=0; i<=len; i++)            
            {
                if(i*i==len) cnt++;
            }
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

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

    string s;
    cin >> s;

    s[k - 1] = tolower(s[k - 1]);
    cout << s << endl;

    return 0;
}


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

#define LL long long
LL n,ans=0,freq[100100],a[100100],bil,tot=0;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>bil;
        if(bil>100000){
            tot++;
        } else {
            freq[bil]++;
        }
    }
    for(int i=1;i<=100000;i++){
        if(freq[i]<i){
            tot+=freq[i];
        }else if(freq[i]>=i){
            tot+=freq[i]-i;
        }
    }
    cout<<tot<<endl;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>
#define int long long

typedef struct {
	int N;
	int *u;
	int *u_rank;
}union_find;

union_find *make_union_find(int N){
	int i;
	union_find *uf = (union_find *)malloc(sizeof(union_find));
	uf->N = N;
	uf->u = (int *)malloc(sizeof(int) * N);
	uf->u_rank = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		(uf->u)[i] = i;
		(uf->u_rank)[i] = 1;
	}
	return uf;
}

int root_uf(int x, union_find *uf){
	int *u = uf->u;
	if(u[x] == x){
		return x;
	}
	else{
		u[x] = root_uf(u[x], uf);
		return u[x];
	}
}

void combine_uf(int x, int y, union_find *uf){
	int x_root = root_uf(x, uf);
	int y_root = root_uf(y, uf);
	int *u = uf->u;
	int *u_rank = uf->u_rank;
	if(x_root == y_root){
		return;
	}
	else if(u_rank[x_root] < u_rank[y_root]){
		u[x_root] = y_root;
		u_rank[y_root] += u_rank[x_root];
		u_rank[x_root] = 0;
	}
	else{
		u[y_root] = x_root;
		u_rank[x_root] += u_rank[y_root];
		u_rank[y_root] = 0;
	}
}

//xとyが同じ集合に属していれば1を,そうでなければ0を返す
int is_same_union_uf(int x, int y, union_find *uf){
	if(root_uf(x, uf) == root_uf(y, uf)){
		return 1;
	}
	else{
		return 0;
	}
}

//xが属する集合の要素数を返す
int rank_uf(int x, union_find *uf){
	return (uf->u_rank)[root_uf(x, uf)];
}

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

int main(){
	int N, M, a, b, i, n1, n2, ans;
	scanf("%lld%lld", &N, &M);
	union_find *uf = make_union_find(N);
	for(i = 0; i < M; i++){
		scanf("%lld%lld", &a, &b);
		combine_uf(a - 1, b - 1, uf);
	}
	n1 = min(rank_uf(0, uf), rank_uf(1, uf));
	n2 = N - n1;
//	printf("(n1, n2) = (%lld, %lld)\n", n1, n2);
	ans = (n1 * (n1 - 1)) / 2 + (n2 * (n2 - 1)) / 2 - M;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int ans=0;
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			int ch=r*i+g*j;
			if((n-ch)<0)break;
			if((n-ch)%b==0)ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N = int(input())
	A = list(map(int, input().split(" ")))
	
	ans = A[0]
	for i, val in enumerate(A):
		if i == 0:
			continue
		ans = lcm(ans, val)
		
	ans -= 1
	tmp = 0
	for i, val in enumerate(A):
		tmp = tmp + (ans % val)
	
	print(tmp)
	
def gcd(a, b):
	if a > b:
		a, b = b, a
		
	while a > 0:
		a, b = b % a, a
	return b
	
def lcm(a, b):
	g = gcd(a, b)
	return a // g * b
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 12260
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a >= b){
			System.out.println("delicious");
		}
		else if (b-a <= x){
			System.out.println("safe");
		}
		else{
			System.out.println("dangerous");
		}
		
		sc.close();
	}
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};

int N, K;

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

    cin >> N >> K;

    vector<double> P;
    CumulativeSum<int> cs(N);
    REP(i, N) {
        int p;
        cin >> p;
        cs.Add(i, p);
        P.push_back(static_cast<double>(p));
    }

    cs.Build();

    int ans_ind = -1;
    int ans_val = -1;

    for(int i = 0; i <= N - K; ++i) {
        int cand = cs.Query(i, i + K - 1);
        if(ans_val < cand) {
            ans_ind = i;
            ans_val = cand;
        }
    }

    double ans = 0;
    for(int i = ans_ind; i < ans_ind + K; ++i) {
        ans += (P[i] + 1.0) / 2.0;
    }

    printf("%.7f\n", ans);

    return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
string s, t; ll v[200005][30];
int main() {
  cin >> s >> t;
  string ss = s+s;
  for(int i = ss.size()-1; i >= 0; --i) {
    for(int j = 0; j < 26; ++j) v[i][j] = v[i+1][j];
    v[i][ss[i]-'a'] = i+1;
  }
  ll ans = 0;
  for(int i = 0, x = 0; i < t.size(); ++i) {
    ans += v[x][t[i]-'a']-x;
    x = v[x][t[i]-'a'];
    if(x == 0) {
      ans = -1;
      break;
    }
    x %= s.size();
  }
  cout << ans << endl;
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	ll n;
	string s;
	cin>>n>>s;
	ll x=s.size()-1;
	string ans[4]={"SS","SW","WS","WW"};
	for(int i=0;i<4;i++){
		for(int j=1;j<x;j++){
			if(s[j]=='o'){
				if(ans[i][j]=='S')ans[i]+=ans[i][j-1];
				else ans[i]+=(ans[i][j-1]=='S'?"W":"S");
			}else{
				if(ans[i][j]=='S')ans[i]+=(ans[i][j-1]=='S'?"W":"S");
				else ans[i]+=ans[i][j-1];
			}
		}
		char c,d;
		if(s[x]=='o'){
			if(ans[i][x]=='S')c=ans[i][x-1];
			else c=(ans[i][x-1]=='S'?'W':'S');
		}else{
			if(ans[i][x]=='S')c=(ans[i][x-1]=='S'?'W':'S');
			else c=ans[i][x-1];
		}
		if(s[0]=='o'){
			if(ans[i][0]=='S')d=ans[i][1];
			else d=(ans[i][1]=='S'?'W':'S');
		}else{
			if(ans[i][0]=='S')d=(ans[i][1]=='S'?'W':'S');
			else d=ans[i][1];
		}
		if(c==ans[i][0]&&d==ans[i][x]){
			cout<<ans[i]<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	int n;
	cin >> n;
	cout << (n * (n + 1) /2) << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int[] ret;
	int[] val = {500, 100, 50, 10, 5, 1};
	int plus = 500;
	void run() {
		Scanner sc = new Scanner(System.in);
		ret = new int[plus];
		fill(ret, INF);
		ret[0] = 0;
		for(int i=0;i<plus;i++) for(int j=0;j<val.length;j++) {
			if( i+val[j] < plus ) ret[i+val[j]] = min(ret[i+val[j]], ret[i]+1);
		}
		
		for(;;) {
			int P = sc.nextInt();
			if(P == 0) break;
			int[] coins = new int[val.length];
			for(int i=val.length-1;i>=0;i--) coins[i] = sc.nextInt();
			int min = INF;
			for(int i = P;i<P+plus;i++) {
				int pay = i;
				int coin = 0;
				for(int j=0;j<val.length;j++) {
					int c = min(pay/val[j], coins[j]);
					pay -= c * val[j];
					coin += c;
				}
				if(pay == 0) min = min(min, coin+ret[i-P]);
//				debug(i, coin);
			}
			
			System.out.println(min);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
A, B, C, X, Y = map(int, input().split())
# 個別に買う
v1 = A * X + B * Y
# 少ない方に合わせてセットを買い、足りない分を買い足す
if X >= Y:
    v2 = C * 2 * Y + (X - Y) * A
else:
    v2 = C * 2 * X + (Y - X) * B
# すべてセットで買う
v3 = C * 2 * max([X, Y])
print(min([v1, v2, v3]))


Measured memory_bytes: 2940
import java.util.*;
 
public class Main {
  
  public static void main(String[] args){
    
  Scanner s=new Scanner(System.in);
    
  Long S=s.nextLong();
  Long A=s.nextLong();
  Long B=s.nextLong();
  
  Long division=S/(A+B);
  Long remainder=S%(A+B);
  
  Long count;
    
  if(remainder<A) count=division*A+remainder;
  else count=division*A+A;
    
  System.out.print(count);
  }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    string X;
    cin >> X;
    int c_s = 0;
    int del_pair = 0;
    for ( int i = 0; i < X.size(); i++ ) {
	if ( X[i] == 'S' ) {
	    c_s++;
	}
	else {
	    if ( c_s > 0 ) {
		c_s--;
		del_pair++;
	    }
	}
    }
    int ans = (int)X.size() - (2 * del_pair);

    printf("%d\n", ans);

    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

void add(int &x, int y) {
   x += y;
   if (x >= mod) x -= mod;
}

const int N = 4005;
int C[N][N];

int get(int n, int k) {
   if (n < k || k < 0) return 0;
   return C[n][k];
}

int main() {
   ios_base::sync_with_stdio(false);
   int n, k;
   cin >> n >> k;
   for (int i = 0; i < N; ++i) {
      C[i][0] = 1;
      for (int j = 1; j <= i; ++j) {
         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
      }
   }
   for (int i = 1; i <= k; ++i) {
      int coef = get(k - 1, i - 1);
      coef = (long long) coef * get(n - k + 1, i) % mod;
      cout << coef << "\n";
   }
}


Measured memory_bytes: 61440