akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 2050;
 ll mod = 1e9+7;

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    map<string,ll> m;
    rep(i,n){
      string s;
      cin >> s;
      sort(all(s));
      m[s]++;
    }
    for(auto t:m){
        ll s = t.second;
        ans+= s*(s-1) / 2;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;

    map<char, int> mp;
    for (int i = 0; i < s.length(); ++i) {
        mp[s[i]]++;
    }

    if ((mp['N'] > 0 && mp['S'] == 0) || (mp['S'] > 0 && mp['N'] == 0)) {
        puts("No");
        return 0;
    }

    if ((mp['W'] > 0 && mp['E'] == 0) || (mp['E'] > 0 && mp['W'] == 0)) {
        puts("No");
        return 0;
    }

    puts("Yes");
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;

const ll MOD = 1000000007;

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

    string S; cin >> S;
    vector<ll> dp(4);
    dp[0] = 1;
    for (char c : S) {
        if (c == 'A') {
            dp[1] = (dp[1] + dp[0]) % MOD;
        }
        else if (c == 'B') {
            dp[2] = (dp[2] + dp[1]) % MOD;
        }
        else if (c == 'C') {
            dp[3] = (dp[3] + dp[2]) % MOD;
        }
        else {
            dp[3] = (dp[3] * 3 + dp[2]) % MOD;
            dp[2] = (dp[2] * 3 + dp[1]) % MOD;
            dp[1] = (dp[1] * 3 + dp[0]) % MOD;
            dp[0] = (dp[0] * 3) % MOD;
        }
    }
    cout << dp[3] << "\n";
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**6)
N = int(input())
bl = [False]*(N+1)
memo = [N]*(N+1)

def f(n):
    if bl[n]:
        return memo[n]
  
    m = N

    i = 0
    while n >= 6**i:
        if n == 6**i:
            bl[n] = True
            memo[n] = 1
            return 1
        m = min(m, f(n-6**i)+1)
        i += 1

    i = 1
    while n >= 9**i:
        if n == 9**i:
            bl[n] = True
            memo[n] = 1
            return 1
        m = min(m, f(n-9**i)+1)
        i += 1
    
    bl[n] = True
    memo[n] = m
    return m

print(f(N)) 

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k, ans =0;
	string s;
	cin >>k >>s;
	if(sz(s) > k) s = s.substr(0,k) + "...";
	cout <<s <<"\n";
	return 0;
	
}


Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var H int
	fmt.Scan(&H)
	i := 1
	ans := 0
	for H != 0 {
		H = H / 2
		ans += i
		i *= 2
		// fmt.Println(H)
		if H == 1 {
			ans += i
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var Q = new Queue<int>[N];
		for(int i=0;i<N;i++){
			Q[i] = new Queue<int>();
			for(int j=0;j<N-1;j++){
				Q[i].Enqueue(A[i][j]);
			}
		}
		
		int d = 0;
		HashSet<int> L = new HashSet<int>();
		for(int i=0;i<N;i++) L.Add(i);
		
		while(true){
			bool update = false;
			HashSet<int> nL = new HashSet<int>();
			foreach(var i in L){
				if(Q[i].Count == 0) continue;
				int j = Q[i].Peek();
				if(Q[j].Peek() == i){
					nL.Add(i);
					nL.Add(j);
					update = true;
				}
			}
			//Console.WriteLine("d:{0}, L:{1}, nL:{2}",d,String.Join(" ",L), String.Join(" ",nL));
			if(update){
				foreach(var ii in nL){
					Q[ii].Dequeue();
				}
				d++;
				L = nL;
				continue;
			} else {
				break;
			}
		}
		
		bool chk = true;
		for(int i=0;i<N;i++){
			chk &= Q[i].Count == 0;
		}
		Console.WriteLine(chk ? d : -1);
		
		
	}
	int N;
	int[][] A;
	public Sol(){
		N = ri();
		A = new int[N][];
		for(int i=0;i<N;i++){
			A[i] = ria();
			for(int j=0;j<N-1;j++) A[i][j]--;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int count = 0;
        int num[] = new int[n];

        for(int i = 0; i < n; i++){
            num[i] = stdIn.nextInt();
        }
        
        Arrays.sort(num);
                
        int k = num[n / 2] - num[n / 2 - 1];
        
        System.out.println(k);
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> X(M);
  for (int i = 0; i < M; i++) cin >> X.at(i);

  sort(X.begin(), X.end());

  vector<int> Y(M - 1);
  for (int i = 0; i < M - 1; i++) {
    Y.at(i) = X.at(i + 1) - X.at(i);
  }

  sort(Y.begin(), Y.end());

  int ans = 0;

  for (int i = 0; i < M - N; i++) {
    ans += Y.at(i);
  }

  cout << ans << endl;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

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

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    int N;
    cin >> N;
    vi A(N);
    for (auto &&e: A) {
        cin >> e;
        e--;
    }

    {
        bool ok = true;
        FOR(i, 1, N) {
            if (A[i - 1] >= A[i])
                ok = false;
        }

        if (ok) return 1;
    }

    int lb = 1;
    int ub = 1e9 + 10;
    while (ub - lb > 1) {

        int med = ((ll) ub + lb) / 2;
        map<int, int> mp;
        FOR(i, 1, N) {
            if (A[i - 1] >= A[i]) {
                // erase A[i]+1
                auto aft = mp.upper_bound(A[i]);
                mp.erase(aft, end(mp));

                mp[A[i]]++;

                int e = A[i];
                while (mp[e] >= med && e > 0) {
                    mp[e - 1] += mp[e] / med;
                    mp[e] = mp[e] % med;
                    e--;
                }
            }
        }

        if (mp[0] >= med) {
            lb = med;
        } else {
            ub = med;
        }
    }

    return ub;
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 200100;
int cnt[maxn];
int use[maxn];
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    int n,k;scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i){
        int d;scanf("%d",&d);
        ++cnt[d];
    }
    int m=0;
    for(int i=1;i<maxn;++i){
        if(cnt[i]){
            use[++m]=cnt[i];
        }
    }
    if(m<=k)printf("0");
    else{
        sort(use+1,use+1+m);
        int del=m-k,ans=0;
        for(int i=1;i<=del;++i)ans+=use[i];
        printf("%d",ans);
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
	int a[100005], n,cnt;
	while (cin >> n)
	{
		cnt = 0;
		for (int i = 1; i <= n; i++)
			cin >> a[i];
		for (int i = 1; i <= n; i++)
		{
			if (a[i] == i)
			{
				swap(a[i], a[i + 1]);
				i++;
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 768
H,N=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]

dp=[[0]*(H+1) for _ in range(N+1)]
dp[0]=[float("inf")]*(H+1)
dp[0][0]=0

for i in range(1,N+1):
  for j in range(1,H+1):
    if j-AB[i-1][0]>=0:
      dp[i][j]=min(dp[i][j-AB[i-1][0]]+AB[i-1][1],dp[i-1][j])
    else:
      dp[i][j]=min(AB[i-1][1],dp[i-1][j])
      
print(dp[N][H])

Measured memory_bytes: 119900
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

const int INF=INT_MAX/3;
const int M = 362880; // =9!
const int G = 46233; //??´????????????????????£?????°
vector<int> check(M,0);
vector<int> preve(M,-1);
vector<int> d(M,INF);

typedef vector<int> Board;

int factorial(int n){
	if(n==0){
		return 0;
	}
	if(n==1){
		return 1;
	}
	return n*factorial(n-1);
}

int translate(Board &b){
	Board bb(9);
	bb=b;
	int S = 0 ;
	for(int i=0;i<9;i++){
		S+=factorial(8-i)*bb[i];
		for(int j=i+1;j<9;j++){
			if(bb[j]>bb[i]){
				bb[j]--;
			}
		}
	}
	return S;
}

void Adj(Board u, vector< Board> &adj){
	int zero;
	for(int i=0;i<9;i++){
		if(u[i]==0){zero=i;}
	}

	if(zero<6){
		Board v(9);
		v=u;
		swap(v[zero],v[zero+3]);
		adj.push_back(v);
	}
	if(zero>2){
		Board v(9);
		v=u;
		swap(v[zero],v[zero-3]);
		adj.push_back(v);
	}
	if(zero%3 == 0 || zero%3 == 1){
		Board  v(9);
		v=u;
		swap(v[zero],v[zero+1]);
		adj.push_back(v);
	}
	if(zero%3 == 1 || zero%3 == 2){
		Board v(9);
		v=u;
		swap(v[zero],v[zero-1]);
		adj.push_back(v);
	}
}

int solve(Board &init){
	Board u(9),v(9);
	int u_code, v_code;
	int init_code = translate(init);

	queue<Board> q;
	q.push(init);
	check[init_code]=1;
	d[init_code]=0;
	preve[init_code]=-1;

	if(init_code==G){
	return d[init_code];
	}

	while(!q.empty()){
		u = q.front();
		q.pop();
		u_code = translate(u);
		vector<Board> adj(0);
		Adj(u, adj);
		for(int i=0;i<adj.size();i++){
			v = adj[i];
			v_code = translate(v);
			if(check[v_code]==0){
				check[v_code]=1;
				d[v_code]=d[u_code]+1;
				preve[v_code]=u_code;
				q.push(v);
			}
			if(v_code==G){
				return d[v_code];
			}
		}
		check[u_code] = 2;
	}
}

int main(){
	Board init(9);
	for(int i=0;i<9;i++){
		cin >> init[i]; 
	} 

	//cout << translate(init) << endl;
	/*
	vector<Board> b(0);
	Adj(init,b);
	for(int i=0;i<b.size();i++){
		for (int j=0;j<9;j++){
			cout << b[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl ;
	*/ 
	cout << solve(init) << endl;
	return 0;
}

Measured memory_bytes: 7080
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> X;
		ans += 2*min(X, abs(X - K));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <bitset>
#include<unordered_map>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
#define endl '\n'
#define exit(s) return cout<<s,0;
#define sz(s) (int)(s.size())
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(), s.rend()
#define watch(x) cout << (#x) << " = " << x << endl
#define DNT ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(allr(t));
	if (s < t)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	
		return 0;
}

Measured memory_bytes: 3092
use proconio::input;

fn main() {
    input! {
        n: i64
    }
    let sum = |n| { n*(n+1)/2 };
    let ans = sum(n) - 3*sum(n/3) - 5*sum(n/5) + 15*sum(n/15);
    println!("{}", ans);
}


Measured memory_bytes: 2124
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, a, b, c) = in.readLine.split(" ").map(_.toInt)
  val tLen = Iterator.continually(in.readInt)
    .take(n)
    .toArray

  val tar = Array(0, a, b, c)

  val ans = dfsEnum(tar.size, n)
  println(ans)
  
  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    // n本の竹を 0:使わない 1:Aに使う 2:Bに使う 3:Cに使う の４進
    val enum = Array.ofDim[Int](n)
    var ret = Int.MaxValue
  
    def evalute():Unit = {
      if(!(1 to 3).forall(i => enum.exists(_ == i))) return
      var mp = 0
      val len = Array.ofDim[Int](d)
      for(j <- 0 until n if enum(j) != 0) {
        val i = enum(j)
        if(len(i) != 0) mp += 10
        len(i) += tLen(j)
      }
      mp += (1 to 3).map(i => (tar(i) - len(i)).abs).sum
      if(ret > mp) ret = mp
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(i <- 0 until d) {
          enum(cnt) = i
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }
}

Measured memory_bytes: 46928
gets
s=(gets.split.map.with_index(1){|n,i|n.to_i==i ??0:?1}*"")
cnt=0
i=0
while s[i+1]
  if s[i,2]=="00"
    s[i,2]=""
    cnt+=1
  else
    i+=1
  end
end
i=0
while s[i+1]
  if s[i,2]=="10"
    s[i,2]=""
    cnt+=1
  else
    i+=1
  end
end
i=0
while s[i+1]
  if s[i,2]=="01"
    s[i,2]=""
    cnt+=1
  else
    i+=1
  end
end
p s[?0]?(cnt+1):cnt

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

using namespace std;

const int inf = 4000000;
const long long mod = 1e9 + 7;

long long fac[inf], finv[inf], inv[inf];

void com_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < inf; i++){
    fac[i] = fac[i - 1] * (long long)i % mod;
    inv[i] = mod - inv[(int)mod % i] * (mod / (long long)i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

int main(){
  int N, K;
  cin >> N >> K;
  
  com_init();
  
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());
  
  long long sum_f = 0;
  for(int i = 0; i <= N - K; i++){
    sum_f += (A[i] * fac[N - i - 1] % mod) * (finv[K - 1] * finv[N - i - K] % mod) % mod;
    while(sum_f < 0) sum_f += mod * 100000ll;
    sum_f %= mod;
  }
  
  reverse(A.begin(), A.end());
  for(int i = 0; i <= N - K; i++){
    sum_f -= (A[i] * fac[N - i - 1] % mod) * (finv[K - 1] * finv[N - i - K] % mod) % mod;
    while(sum_f < 0) sum_f += mod * 100000ll;
    sum_f %= mod;
  }
  
  cout << sum_f << endl;
  
  return 0;
}


Measured memory_bytes: 94720
#include <iostream>
int main()
{
    int x,y,z,K;
    std::cin>>x>>y>>z>>K;
if(x>=K)
std::cout<<K;

 else if(x+y>=K)
    std::cout<<x;

    else
    {
        std::cout<<2*x+y-K;
    }
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <algorithm>
using namespace std;
int N, T, L, B, A; bool lose[101], back[101]; long double dp[101][101];
int main() {
	while (true) {
		scanf("%d%d%d%d", &N, &T, &L, &B);
		if (N == 0 && T == 0 && L == 0 && B == 0) break;
		for (int i = 0; i <= N; i++) lose[i] = false, back[i] = false;
		for (int i = 0; i < L; i++) scanf("%d", &A), lose[A] = true;
		for (int i = 0; i < B; i++) scanf("%d", &A), back[A] = true;
		for (int i = 0; i <= T; i++) for (int j = 0; j <= N; j++) dp[i][j] = 0.0L;
		dp[0][0] = 1.0;
		for (int i = 0; i < T; i++) {
			for (int j = N - 1; j >= 0; j--) {
				if (back[j]) {
					dp[i][0] += dp[i][j]; dp[i][j] = 0.0L;
				}
				else if (lose[j]) {
					if (i + 1 != T) { 
						for (int k = 1; k <= 6; k++) {
							dp[i + 2][min(j + k, 2 * N - (j + k))] += dp[i][j] / 6.0L;
						}
					}
				}
				else {
					for (int k = 1; k <= 6; k++) {
						dp[i + 1][min(j + k, 2 * N - (j + k))] += dp[i][j] / 6.0L;
					}
				}
			}
		}
		long double ret = 0.0L;
		for (int i = 1; i <= T; i++) ret += dp[i][N];
		printf("%.9Lf\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,t;
  cin >> n >> t;
  int ans = 1e9;
  rep(i,n){
    int c,ti;
    cin >> c >> ti;
    if(ti<=t) ans = min(ans,c);
  }
  if(ans>100000) cout << "TLE" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        long sum = n * (n + 1) / 2 - n;
        Console.WriteLine(sum.ToString());

    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=100010;

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

    int x;
    cin>>x;
    x=x^1;
    cout<<x;

    return (0);
}


Measured memory_bytes: 3632
n, k = list(map(int, input().split(' ')))
s = input().strip()

t = []
c = '0'
v = 0
for i in range(n):
    if c != s[i]:
        t.append(v)
        v = 1
        c = s[i]
    else:
        v += 1
t.append(v)

r = 0
temp = 0
result = 0
for l in range(0, len(t), 2):
    while (r - l) // 2 + 1 <= k and r < len(t):
        temp += t[r]
        if r + 1 < len(t):
            temp += t[r + 1]
        r += 2
    result = max([temp, result])

    if r == l:
        r += 2
        if r - l < len(t):
            temp += t[r - 1] 
    else:
        temp -= t[l]
        if l - 1 > 0:
            temp -= t[l - 1]

print(result)


Measured memory_bytes: 45808
#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 all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(c - a) <= d) || ((abs(b - a) <= d) && (abs(c - b) <= d))){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int n,p;
    int map[101][101];
    memset(map,10000,sizeof(map));
    cin >> n;
    REP(i,n){
	int r,k,t;
	cin >> r >> k;
	REP(j,k){
	    cin >> t;
	    map[r][t] = 1;
	}
    }
    n++;
    while(true){
	bool flg = false;
	REP(k,n){
	    REP(i,n){
		REP(j,n){
		    if(map[i][j] > (map[i][k] + map[k][j])){
			flg = true;
			map[i][j] = map[i][k] + map[k][j];
		    }
		}
	    }
	}
	if(!flg) break;
    }

    cin >> p;
    REP(a,p){
	int s,d,v;
	cin >> s >> d >> v;
	if(map[s][d] < v) cout << map[s][d]+1 << endl;
	else cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
#define mod2 998244353

using namespace std;
ll n;
struct p {
	int f;
	int s;
	p(int l, int r) {
		f = l;
		s = r;
	}
	bool operator<(const p& right) const {
		return f < right.f;
	}
};
vector<ll> v1;
vector<ll> v2;
int m[200005];
int main() {
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;

	}
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val MOD = 1000000007L
    val N = nextInt()
    val S1 = next()
    val S2 = next()
    var ans = 1L
    var i = 0
    var f = 3L
    var yoko = false
    while (i < N) {
        if (i == N - 1 || S1[i] != S1[i + 1]) {
            ans = (ans * f) % MOD
            f = 2L
            yoko = false
            i++
        } else {
            if (yoko) {
                ans = (ans * 3) % MOD
            } else if (i == 0) {
                ans = (ans * 6) % MOD
            } else {
                ans = (ans * 2) % MOD
            }
            f = 1L
            yoko = true
            i += 2
        }
    }
    println(ans)
}

Measured memory_bytes: 33808
package main

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

func main() {
	sc = initScanner(os.Stdin)
	N := scanInt(sc)

	A := scanIntSlice(sc, N)

	fmt.Println(resolve(N, A))
}

func resolve(N int, A []int) int {

	count := 0
	next := true
	for {
		for i := 0; i < N; i++ {
			if isOdd(A[i]) {
				next = false
				break
			} else {
				A[i] /= 2
			}
		}
		if !next {
			break
		}
		count++
	}
	return count
}

func isOdd(num int) bool {
	if num%2 == 1 {
		return true
	} else {
		return false
	}
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0; i<s.size(); i++)
    {
        if(i+2==s.size())
            break;
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            cnt++;
            i+=2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3572
N,M=map(int,input().split())

student=[list(map(int,input().split())) for n in range(N)]

check=[list(map(int,input().split())) for m in range(M)]

for n in range(N):
  man=400000001
  for m in range(M):
    dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
    point=m+1
    if dis<man:
      man=dis
      ans=point
  print(ans)
  

Measured memory_bytes: 3064
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

#include<bits/stdc++.h>
using namespace std ;

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

void solve()
{
	int n ;
	cin >> n ;
	int a[n] ;
	int sum = 0 ;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> a[i] ;
	}
	sort(a, a + n, greater<int>()) ;
	int k = 1 ;
	sum += a[0] ;
	int i = 1 ;
	while(k < n - 1)
	{
		if(n - k - 1 >= 2)
		{
			sum += 2*a[i] ;
			i++ ;
			k += 2 ; 
		}
		else
		{
			sum += a[i] ;
			i++ ;
			k++ ;
		}
	}
	cout << sum << endl ;
}

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

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

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int INF = 2e9;

int a[20], b[20], dp[1<<18][55];

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

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

    memset(dp, 127, sizeof(dp));
    dp[0][1] = 0;
    for (int mask=0; mask<1<<n; mask++)
        for (int i=1; i<=50; i++) {
            int pos = __builtin_popcount(mask), cnt = 0;
            for (int j=0; j<n; j++) {
                if (!(mask & (1 << j))) {
                    int val = pos % 2 == j % 2 ? a[j] : b[j];
                    if (val >= i)
                        dp[mask | (1 << j)][val] = min(dp[mask | (1 << j)][val], dp[mask][i] + pos - cnt);
                } else {
                    cnt++;
                }
            }
        }
    int ret = *min_element(dp[(1 << n) - 1] + 1, dp[(1 << n) - 1] + 51);
    cout << (ret >= INF ? -1 : ret) << "\n";

    return 0;
}


Measured memory_bytes: 59900
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,X,D; cin>>N>>X>>D;
    if(D==0){
        if(X==0) cout<< 1 <<"\n";
        else cout<< N+1 <<"\n";
        return;
    }
    if(D<0){
        D=-D;
        X=-X;
    }
    map<ll,vector<P>> mp;
    rep(k,N+1){
        ll kxmodd=( (k*X)%D>=0 ? (k*X)%D : (-(k*X)%D)+D );
        ll kxmodsho=( X<0 ? (k*X)/D -1 : (k*X)/D );
        ll left=kxmodsho+(k*(k-1))/2;
        ll right=kxmodsho+((2*N-k-1)*k)/2;
        mp[kxmodd].emplace_back(left,right);
    }
    ll ans=0;
    for(auto& x: mp){
        auto& pev=x.second;
        SORT(pev);
        ll right=-INF2;
        for(auto& pe: pev){
            ll le=pe.first;
            ll ri=pe.second;
            if(ri<=right) continue;
            if(le>right){
                ans+=ri-le+1;
            }
            else{
                ans+=ri-right;
            }
            right=ri;
        }
    }
    cout<< ans <<"\n";
}

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


Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){   
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> st[26];
    for(int i = 0; i < n; i++){
        st[s[i] - 'a'].insert(i);
    }
    int q;
    cin >> q;
    for(int c = 0; c < q; c++){
        int w;
        cin >> w;
        if(w == 1){
            int pos;
            char c;
            cin >> pos >> c;
            pos--;
            st[s[pos] - 'a'].erase(pos);
            st[c - 'a'].insert(pos);
            s[pos] = c;
        }
        else{
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            for(int i = 0; i < 26; i++){
                if(st[i].lower_bound(l) != st[i].end() && *st[i].lower_bound(l) <= r) ans++;
            }
            cout << ans << endl;
        }
    }
}

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

using namespace std;

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

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

  vector<int> dp(n, 1e9+5);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int k = i - 1; k >= max(i - K, 0); --k) {
      dp[i] = min(dp[i], dp[k] + abs(h[i] - h[k]));
    }
  }
  cout << dp[n-1] << '\n';

  return 0;
}


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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      (rinv*=inverse(k))%=MOD;
      if(k%2) (res+=MOD-rinv)%=MOD;
      else (res+=rinv)%=MOD;
    }
    for(Int i=1;i<=n;i++)
      (res*=i)%=MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<mod.C(k,n)<<endl;
  return 0;
}



Measured memory_bytes: 7456
#include<iostream>
using namespace std;
#include<cstdio>
#include<cstring>
int main()
{
  int i,M,n,j;
  int a[100000];
  j=0;
  cin>>n;
	for(i=1;i<100000;i++)
	{
		M=i*i;
			if(M<=n)
			{
				a[j]=M;
				j++;
			}
			else
				break;
	}
				cout<<a[j-1];
}

Measured memory_bytes: 384
lines = []

while line = gets
  lines << line.chomp.split(' ').map(&:to_i)
end

lines.each do |line|
  next if line[0] == 0 && line[1] == 0
  line[0].times do
    hash = []
    line[1].times { hash << "#" }
    puts hash.join('')
  end
  puts "\n"
end


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

#define ntest 0

using namespace std;

int h,w, ch,cw, dh, dw, x, y, r, c;
char s[1005][1005];
int vis[1005][1005];
int b[1005][1005], res[1005][1005];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int valid(int i, int j) {
    if (i > h || i < 1 || j > w || j < 1 || s[i][j]=='#') return 0;
    return 1;
}
void solve() {
    cin >> h >> w >> ch >> cw >> dh >> dw;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> s[i][j];
            res[i][j] = INT_MAX >> 1;
        }
    }
    deque<pair<int,int>> dq;
    dq.push_front({ch, cw});
    res[ch][cw] = 0;
    while(!dq.empty()) {
        pair<int,int> p = dq.front();
        dq.pop_front();
        x = p.first, y = p.second;
        //cout << "x: " << x << " y: " << y << '\n';
        vis[x][y] = 1;
        for (int i = 0; i < 4; ++i){
            r = x + dx[i];
            c = y + dy[i];
            if (valid(r, c) && !vis[r][c]) {
                res[r][c] = min(res[r][c], res[x][y]);
                dq.push_front({r,c});
            }
        }
        if (!b[x][y]) {
            b[x][y] = 1;
            for (int i = x - 2; i <= x + 2; ++i)
            for (int j = y - 2; j <= y + 2; ++j) {
                if (valid(i,j)) {
                    res[i][j] = min(res[i][j], res[x][y] + 1);
                    dq.push_back({i,j});
                }
            }
        }
    }
    if (!vis[dh][dw]) cout << -1;
    else cout << res[dh][dw];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 17212
using System;
using System.Collections.Generic;
using System.Linq;

namespace College
{
    class Program
    {
        static string Join(int[] input)
        {
            string result = "";
            foreach(int i in input)
                result += (" " + i.ToString());
            return result;
        }

        static void Main(string[] args)
        {
            List<List<int[]>> college = new List<List<int[]>>();

            for(int i = 0; i < 4; i++)
            {
                college.Add(new List<int[]>());
                for(int j = 0; j < 3; j++)
                {
                  college[i].Add(new int[10]);
                  for(int k = 0; k < 10; k++)
                      college[i][j][k] = 0;
                }          
            }

            int limit = int.Parse(Console.ReadLine());

            for(int i = 0; i < limit; i++)
            {
                int[] _c = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
                college[_c[0] - 1][_c[1] - 1][_c[2] - 1] = college[_c[0] - 1][_c[1] - 1][_c[2] - 1] + _c[3];
            }

            for(int j = 0; j < college.Count; j++)
            {
                List<int[]> b = college[j];
                foreach(int[] r in b)
                    Console.WriteLine(Join(r));
                if(j != college.Count - 1)
                    Console.WriteLine(new string('#', 20));
            }
        }
    }
}

Measured memory_bytes: 9772
#include <iostream>
using namespace std;
int main() {
	int a, b;
	char op;
	for (;;) {
		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << endl;
		}
		if (op == '-') {
			cout << a - b << endl;
		}
		if (op == '*') {
			cout << a * b << endl;
		}
		if (op == '/') {
			cout << a / b << endl;
		}
		if (op == '?') {
			return 0;
		}

	}
}


Measured memory_bytes: 3120
import java.util.*;
import java.lang.*;

public class Main {
	static int group(int x) {
		switch (x) {
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				return 0;
			case 4:
			case 6:
			case 9:
			case 11:
				return 1;
			case 2:
				return 2;
			default:
				return -1;
		}
	}

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		System.out.println((group(x) == group(y))?"Yes":"No");
	}
}

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(B<C||D<A){
    cout<<0<<endl;
  }else{
    cout<<min(B,D)-max(A,C)<<endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{


	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
		for(;;){

			String str=reader.readLine();
			String[] str_Array=str.split(" ");

			int x=Integer.parseInt(str_Array[0]);
			int y=Integer.parseInt(str_Array[1]);

			if(x==0&&y==0)break;

			if(x>y){System.out.println(y+" "+x);}
			else{System.out.println(x+" "+y);}

		}
		}catch(IOException e){
			System.out.println("??¨??????:"+e);

		}

	}

}

Measured memory_bytes: 26896
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 //   freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    long long int ctr =0 ;
    for(int i=0;i<=n/r+1;i++)
    {
        for(int j=0;j<=n/g+1;j++)
        {
            // cout<<i<<" "<<j<<endl;
            int cvr = i*r+j*g;
            if(cvr>n)
                continue;
            if((n-cvr)%b==0)
            {
                ctr++;
            }
        }
    }
    cout<<ctr;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

s = 0
for i in range(min(N, K) + 1):
  # res = C + D
  res = K - i
  
  # i = A + B
  for j in range(i + 1):
    # j: B, k: A
    k = i - j
    
    # Jewel in hand
    Q = sorted(V[:j] + V[N - k:])
    
    # Number of negative jewels
    minus = sum([q < 0 for q in Q])
    
    # Drop some of negative, and sum up
    score = sum(Q[min(minus, res):])
    
    # Update score
    s = max(s, score)

print(s)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<int,int>;

int INF = 1e9+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;};//演算子オーバーロード

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

  priority_queue<ipair,vector<ipair>,greater<ipair>> task;

  rep(i, N){
    int a, b;
    cin >> a >> b;
    task.push(make_pair(b, a));
  }

  ll time = 0;

  while(!task.empty()){
    pair<ll, ll> p = task.top(); task.pop();
    if(time + p.second > p.first){
      cout << "No" << endl;
      return 0;
    }
    time += p.second;
  }

  cout << "Yes" << endl;

  return 0;
}

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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

string s, t;
int a, b;
void Input() {

    cin >> s >> t;
    cin >> a >> b;
}



void Solve() {


    string u;
    cin >> u;
    if(u == s) {

        a--;
        cout << a << " " << b << endl;

    }
    else if(u == t) {

        b--;
        cout << a << " " << b << endl;
    }
    else cout << a << " " << b << endl;


}

int main() {

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


  return 0;

}



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

int main(){
    cin >> s;
    int mx = 0;
    int l = 0; int r =0;
    while(r<3){
        if(s[r]==s[l]){
            r++;
        }
        else{
            if(s[l]=='R'){
                mx = max(mx,r-l);
            }
            l=r;
        }
    }
    if(s[l]=='R'){
        mx = max(mx,r-l);
    }
    cout << mx << endl;
}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int a[100000]={0};
    cin>>n;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        a[s]++;
    }
    int ans=0;
    for(int i=1;i<99999;i++){
        ans=max(a[i-1]+a[i]+a[i+1],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int x = 1;
        int result = 0;
        while (x < B) {
            x += (A - 1);
            result++;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>

int main() {
  int grid[3][3];
  bool flag = true;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      std::cin >> grid[i][j];
    }
  }
  for (int i = 1; i < 3; ++i) {
    if (grid[i][0] - grid[0][0] != grid[i][1] - grid[0][1] || grid[i][0] - grid[0][0] != grid[i][2] - grid[0][2])
    flag = false;
  }
  for (int i = 1; i < 3; ++i) {
    if (grid[0][i] - grid[0][0] != grid[1][i] - grid[1][0] || grid[0][i] - grid[0][0] != grid[2][i] - grid[2][0])
      flag = false;
  }
  std::cout << (flag ? "Yes" : "No") << std::endl;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int a, b, n;
    while (scanf("%d %d %d", &a, &b, &n) != EOF)
    {
        int ans = 0;
        while (n--)
        {
            a *= 10;
            ans += (a / b) % 10;
            a %= b;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3240