akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll MOD = 1e9 + 7;
vector<vector<ll>> nCk(2001, vector<ll>(2001, 0));

void calc() {
  int N = 2001;
  nCk[0][0] = 1;
  for (int i = 1; i < N; i++)
  {
    nCk[i][0] = 1;
    for (int j = 1; j < N; j++)
    {
      nCk[i][j] = (nCk[i - 1][j - 1] + nCk[i - 1][j]) % MOD;
    }
    
  }
  
}

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

  calc();
  int N, K; cin >> N >> K;
  for (int i = 1; i <= K; i++)
  {
    ll ans = nCk[N - K + 1][i] * nCk[K - 1][i - 1];
    cout << (ans % MOD) << '\n';
  }
  
  return 0;
}


Measured memory_bytes: 31616
#include<iostream> 

using namespace std;

// int型に収まりきらないので変えた。
// 正しい型を書くのが面倒になったのでテンプレートで型推論させる。
template<typename T>
T func(T x) {
	return x <= 1 ? 1 : x * func(x - 1);
}

int main() {
	long long n;

	cin >> n;

	cout << func(n) << endl;

	return 0;
}

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

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
typedef vector<LL> V;
const LL INF=1e17;
int main(){
    int N,M,L;
    cin>>N>>M>>L;
    V onp(N);
    V sum(M+1,0);
    for(auto &it:onp)cin>>it;
    for(int i=1;i<=M;i++){
        cin>>sum[i];
        sum[i]+=sum[i-1];
    }
    sort(onp.begin(),onp.end());
    auto f=[&](int a,int b){
        return (sum[b]-sum[a-1])/L;
    };
    V dp(1,f(onp[0],onp[1]));
    for(int i=2;i<N;i++){
        V nxt(i,INF);
        for(int j=0;j<i-1;j++){
            nxt[j]=min(nxt[j],dp[j]+f(onp[i-1],onp[i]));
            nxt[i-1]=min(nxt[i-1],dp[j]+f(onp[j],onp[i]));
        }
        swap(dp,nxt);
    }
    LL res=INF;
    for(int i=0;i<N-1;i++)
        res=min(res,dp[i]+f(onp[i],onp.back()));
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3644
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll A,B;cin>>A>>B;
    ll cnt;
    if(B<=1){
        cout<<0<<"\n";
        exit(0);
    }
    REP(i,20){
        if(A+(A-1)*i>=B){
            cout<<i+1<<"\n";
            exit(0);
        }
    }

}



Measured memory_bytes: 256
t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]:fmax(t[c][j],(t[c][j-a]+b));
		for(j=0;t[0][j]!=t[0][W];j++);
	}
} 

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int> >co;
long double f(pair<int, int>x, pair<int, int>y){
	return (long double)sqrt((long double)(y.first-x.first)*(y.first-x.first)+(long double)(y.second-x.second)*(y.second-x.second));
}
long long fact(int x){
	long long tmp=1ll;
	for(int i=x; i>=1; i--){
		tmp*=(long long)i;
	}
	return tmp;
}
int times[9]={0, 0, 2, 4, 12, 48, 240, 1440, 10080};
int main(){
	int n; cin>>n;
	for(int i=0; i<n; i++){
		int x, y; cin>>x>>y;
		co.push_back({x, y});
	}
	long double disttot=0.0;
	for(int i=0; i<n; i++){
		for(int j=0; j<i; j++){
			disttot+=f(co[i], co[j]);
		}
	}
	disttot*=(long double)times[n];
	disttot/=(long double)fact(n);
	cout<<fixed<<setprecision(10)<<disttot<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    ll n=0;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    ll o=0;
    vector<ll> x(n);
    rep(i, n)
    {
        cin >> a[i];
        if (i % 2 != 0)
        {
            o += a[i];
        }
        sum += a[i];
    }
    x[0] = sum - 2 * o;
    //1~n-1までを求めたい。
    for (int i = 1; i < n; i++)
    {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    for (int g : x)
    {
        cout << g << " ";
    }
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3])
            WriteLine("Bad");
        else WriteLine("Good");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  vector<int> cnt(2, 0);
  REP(i, (int)s.length()){
    int x = s[i] - '0';
    cnt[x]++;
  }

  cout << 2 * min(cnt[0], cnt[1]) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;

void solve(void){
    ll A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C) {
        cout << ((A%2)?0:-1) << endl;
        return;
    }
    ll ans = 0;
    while (!(A&1) && !(B&1) && !(C&1)) {
        ans++;
        ll x = (B+C)/2, y = (C+A)/2, z = (A+B)/2;
        A = x, B = y, C = z;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
 
public class Main{
	
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	final int n = sc.nextInt();
    	
    	int[][] melody = new int[n][3];
    	for(int i = 0; i < n; i++){
    		for(int j = 0; j < 3; j++){
    			melody[i][j] = sc.nextInt();
    		}
    	}
    	
    	int[] dp = new int[393 + 1];
    	Arrays.fill(dp, -1);
    	dp[0] = 0;
    	
    	for(int i = 0; i < n; i++){
    		for(int len = melody[i][0]; len <= melody[i][1]; len++){
    			for(int j = 0; j <= 393 - len; j++){
    				if(dp[j] >= 0){
    					dp[j + len] = Math.max(dp[j + len], dp[j] + melody[i][2]);
    				}
    			}
    		}
    	}
    	
    	//System.out.println(Arrays.toString(dp));
    	
    	final int m = sc.nextInt();
    	
    	int[] array = new int[m];
    	for(int i = 0; i < m; i++){
    		array[i] = dp[sc.nextInt()];
    		if(array[i] == -1){
    			System.out.println(-1);
    			return;
    		}
    	}
    	
    	for(int num : array){
    		System.out.println(num);
    	}
    }
     
}

Measured memory_bytes: 23700
import sys
input  =  sys.stdin.readline

s = input()
t = input()
dp = [[0]*(len(t) + 1) for i in range(len(s) + 1)]
for i in range(1,len(dp)):
    for j in range(1,len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1])
out = ''
i = len(s)
j = len(t)
while i != 0 and j != 0:
    if s[i - 1] == t[j - 1]:
        out += s[i - 1]
        i -= 1
        j -= 1
    elif dp[i][j - 1]>dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
print(out[::-1])


Measured memory_bytes: 112476
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> f(N, 0);

	int root_n = (int)sqrt(N);

	for (int x = 1; x <= root_n; x++) {
		for (int y = 1; y <= root_n; y++) {
			for (int z = 1; z <= root_n; z++) {
				int v = x * x + y * y + z * z + x * y + y * z + z * x;
				if (v <= N) f[v - 1]++;
			}
		}
	}

	for (int i = 0; i < N; i++) cout << f[i] << endl;

	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
void solve(){
      int n;
      cin>>n;
      vector<int> arr(n);
      for(auto&x :arr)  cin>>x;
      int cnt=0;
      sort(arr.begin(),arr.end());
      for(int i=0;i<n-2;i++){
			
			for(int j=i+1;j<n-1;j++){
					if(arr[j]==arr[i])
						continue;
					for(int k=j+1;k<n;k++){
							if(arr[j]==arr[k])
								continue;
							if(arr[i] +arr[j] >arr[k])
								cnt++;
					}
			}
	  }
	  cout<<cnt<<endl;
    
}

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


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

using namespace std;
using i64 = int64_t;


signed main(){
    
    i64 n, s, t;
    cin >> n >> s >> t;
    --s, --t;
    
    auto f = [&](i64 u, i64 v){
        cout << "? " << u + 1 << " " << v + 1 << endl;
        i64 x;
        cin >> x;
        return x;
    };
    
    vector<i64> r_s(n), r_t(n);
    i64 st = i64(1e18);
    for(int i = 0; i < n; ++i){
        r_s[i] = (i == s ? 0 : f(i, s));
        r_t[i] = (i == t ? 0 : f(i, t));
        st = min(st, r_s[i] + r_t[i]);
    }
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
    for(int i = 0; i < n; ++i)
        if(r_s[i] + r_t[i] == st && s != i)
            que.emplace(r_s[i], i);
        
    vector<int> ans(1, s);
    while(!que.empty()){
        i64 len, pos;
        tie(len, pos) = que.top();
        que.pop();
        i64 f1 = f(pos, ans.back());
        if(r_s[ans.back()] + f1 == r_s[pos] && f1 + r_s[ans.back()] + r_t[pos] == st)
            ans.emplace_back(pos);
    }
    cout << "!";
    for(auto& x : ans)
        cout << " " << x + 1;
    cout << endl;
}


Measured memory_bytes: 4680
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=100000;
char s[maxn];
int main()
{
    int i,f1=0,f2=0,len;
    scanf("%s",s);  len=strlen(s);
    for(i=0;i<len;i++)
    {
        if(s[i]=='C')f1=1;
        if(s[i]=='F'&&f1)f2=1;
    }
    if(f2)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	if(a==b) cout<<"Draw";
	else if(a==1) cout<<"Alice";
	else if(b==1) cout<<"Bob";
	else if(a>b) cout<<" Alice";
	else if(b>a) cout<<"Bob";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  for(int i=0;i<S.length();i++){
    int count=0;
    for(int j=0;j<S.length();j++){
      if(T[j]==S[(i+j)%S.length()]) count++;
    }
    if(count==S.length()){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int h, w;
int id(int x, int y){
    return x * w + y;
}
bool C[1000006];
bool ok(int i,int j){
    return 0<= i and i < h and 0 <= j and j < w and C[id(i, j)];
}
int dist[4][1000006];
struct state{
    int d,left,id,dist;
    state(int a, int b, int c, int dist):d(a),left(b),id(c),dist(dist){}
};
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> h >> w >> k;
    rep(i,h*w)rep(j,4)dist[j][i] = 1<<30;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;b--;c--;d--;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w)if(s[j]=='.')C[i * w + j] = true;
    }
    rep(i,4)dist[i][id(a,b)] = 0;
    deque<state> q;
    rep(i,4)q.emplace_back(i, 0, id(a,b), 0);
    while(!q.empty()){
        auto p = q.front();
        q.pop_front();
        const int x = p.id / w;
        const int y = p.id % w;
        const int z = p.id;
        if(dist[p.d][z] != p.dist)continue;
        rep(i,4){
            const int xx = x + dx[i];
            const int yy = y + dy[i];
            const int zz = id(xx, yy);
            if(!ok(xx,yy))continue;
            if(i == p.d){
                if(p.left > 0){
                    if(dist[i][zz] > dist[p.d][z]){
                        dist[i][zz] = dist[p.d][z];
                        q.emplace_front(i, p.left - 1, zz, dist[i][zz]);
                    }
                }else{
                    if(dist[i][zz] > dist[p.d][z] + 1){
                        dist[i][zz] = dist[p.d][z] + 1;
                        q.emplace_back(i, k - 1, zz, dist[i][zz]);
                    }
                }
            }else{
                if(dist[i][zz] > dist[p.d][z] + 1){
                    dist[i][zz] = dist[p.d][z] + 1;
                    q.emplace_back(i, k - 1, zz, dist[i][zz]);
                }
            }
        }
    }
    int ans = min({dist[0][id(c, d)],dist[1][id(c, d)],dist[2][id(c, d)],dist[3][id(c, d)]});
    if(ans == 1<<30)ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 23960
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;

vector<P> table[100000];
vector<bool> used(100000);
vector<ll> ans(100000);

void dfs(ll x,ll y){
	ll res=0;
	for(int i=0;i<table[x].size();i++){
		ll to=table[x][i].first,cost=table[x][i].second;
		if(used[to]) continue;

		res=cost+y;
		used[to]=true;
		ans[to]=res;
		dfs(to,res);
	}
	return ;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,Q,K;
	cin>>N;
	for(int i=0;i<N-1;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		table[a].push_back(make_pair(b,c));
		table[b].push_back(make_pair(a,c));
	}
	cin>>Q>>K;
	K--;
	vector<ll> x(Q),y(Q);
	for(int i=0;i<Q;i++)cin>>x[i]>>y[i];

	fill(used.begin(),used.end(),false);
	used[K]=true;
	ans[K]=0;
	dfs(K,0);

	//for(int i=0;i<5;i++) cout<<ans[i]<<" ";
	for(int i=0;i<Q;i++){
		cout<<ans[x[i]-1]+ans[y[i]-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<int> cnt(n,0);
  for(int i=1;i<n;i++){
    int a;
    cin>>a;
    a--;
    cnt[a]++;
  }
  for(int c:cnt) cout<<c<<newl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s[5] == '1' || (s[5] == '0' && s[6] >= '5')) cout << "TBD\n";
  else cout << "Heisei\n";
}

Measured memory_bytes: 3576
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i], b[i] = a[i];
	sort(all(a));
	unordered_map<int, int> pos;
	rep(i, n) pos[b[i]] = i;
	int ans = 0;
	rep(i, n) ans += (abs(i - pos[a[i]]) & 1);
	cout << ans / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y; cin>>x>>y;
  if(y%2!=0){cout<<"No"; return 0;}
  if(y>=x*2 && y<=x*4){
      cout<<"Yes";
  }
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 3628
// C - Anti-Division
//20190913

using System;
using System.Linq;
using static System.Math;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long a = abcd[0];
            long b = abcd[1];
            int c = (int)abcd[2];
            int d = (int)abcd[3];

            long numOfMultipleC = NumOfMultiple(a, b, c);
            long numOfMultipleD = NumOfMultiple(a, b, d);

            long leastCommonMultipleCD = LeastCommonMultiple(c, d);
            long numOfMultipleCD = NumOfMultiple(a, b, leastCommonMultipleCD);

            long ans = b - a + 1 - numOfMultipleC - numOfMultipleD + numOfMultipleCD;

            Console.WriteLine(ans);

        }

        static long NumOfMultiple(long min, long max, long div)
        {
            return (max / div) - ((min - 1) / div);

            // long minMultiple = 0;

            // for (long i = a; i < a + c && i < b; i++)
            // {
            //     if (i % c == 0)
            //     {
            //         minMultiple = i;
            //         return (long)(int)(1 + ((b - minMultiple) / c));
            //     }
            // }
            // return 0;
        }

        static long LeastCommonMultiple(long m, long n)
        {

            return m / GCD(m, n) * n;
        }

        static long GCD(long m, long n)
        {
            while (true)
            {
                if(n == 0) return m;
                m %= n;
                if(m == 0) return n;
                n %= m;
            }
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
lst = list(map(int, input().split()))
alice = []
bob = []
lst.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice.append(lst[i])
    else:
        bob.append(lst[i])

dif = sum(alice) - sum(bob)
print(dif)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, K; cin >> N >> K;
  string s; cin >> s;

  int cnt = 0;
  rep(i,N){
    if (i==0) continue;
    if (s[i]!=s[i-1]){
      char c = s[i-1];
      while (i<N && s[i]!=c) {
        s[i] = c;
        i++;
      }
      cnt++;
      if (cnt==K || i==N) break;
    }

  }
  int ans = 0;
  rep(i,N){
    if (s[i]=='L'){
      if (i==0) continue;
      else if (s[i-1]=='L') ans++;
    }
    else {
      if (i==N-1) continue;
      else if (s[i+1]=='R') ans++;
    }
  }
  cout << ans << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>

int main(){
  int n,x=0,max=0;
  char s[110];
  scanf("%d",&n);
  scanf("%s",s);
  for(int i=0;i<n;i++){
    if(s[i]=='I')
      x++;
    else
      x--;
    if(max<x)
      max=x;
  }
  printf("%d\n",max);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    ll a[n]; zep(i, 0, n)cin >> a[i];

    zep(i, 0, n - k){
        print((a[i] < a[i + k])? "Yes" : "No")
    }
    
    return 0;
}

Measured memory_bytes: 5188
from collections import deque
sa = deque(list(input()))
sb = deque(list(input()))
sc = deque(list(input()))

flag = True
next = sa
while flag:
    x = next.popleft()
    if x =='a':
        if not sa:
            print('A')
            break
        next = sa
    elif x =='b':
        if not sb:
            print('B')
            break
        next = sb
    else:
        if not sc:
            print('C')
            break
        next = sc

Measured memory_bytes: 64884
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 50 + 10;
char a1[N],a2[N];
int main() {
    int n;
    scanf("%d",&n);
    scanf("%s%s",a1,a2);
    int p=-1;
    LL sum=1;
    for(int i=0;i<n;i++) {
        if(a1[i]==a1[i+1]) {
            if(p==-1) sum*=6;
            else if(p==1) sum*=2;
            else if(p==2) sum*=3;
            p=2;
            i++;
        }
        else {
            if(p==-1) sum*=3;
            else if(p==1) sum*=2;
            else if(p==2) sum*=1;
            p=1;
        }
    }
    printf("%lld\n",sum%MOD);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

bool comp(const pair<string,int>& p,const pair<string,int>& q){
    return p.second > q.second;
  }

int main(){


    int n,a,b,c;
    char t;
    string s;
    cin >> n;

    while(n){
        vector<pair<string,int> > arr;
        REP(i,n){
            cin >> s >> a >> b >> c;
            arr.push_back(make_pair(s,3*a+c));
        }

        sort(arr.begin(),arr.end(),comp);
        REP(i,arr.size()){
            cout << arr[i].first << ',' << arr[i].second << endl;
        }
        cin >> n;
        if(n){
            cout << endl;
        }
    }

    return 0;
}



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

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

    vector<pair<int, pair<int, int>>> program(n);// (c, (s,t))
    for(int i=0; i<n; i++){
        cin >> program[i].second.first 
            >> program[i].second.second 
            >> program[i].first;
    }
    sort(program.begin(),program.end());

    vector<int> rec(2000010);
    int s = program[0].second.first;
    int t = program[0].second.second;
    for(int i=0; i<n; i++){
        if(i < n - 1 
        && program[i].first         == program[i+1].first
        && program[i].second.second == program[i+1].second.first){
            t = program[i+1].second.second;
        }
        else{
            //cout << s << " " << t << endl;
            rec[2 * s - 1] += 1;
            rec[2 * t]     -= 1;

            if(i < n - 1){
                s = program[i+1].second.first;
                t = program[i+1].second.second;
            }
        }
    }

    int ans = 0;
    for(int i=1; i<200010; i++){
        rec[i] += rec[i-1];
        ans = max(ans, rec[i]);
    }
    //for(int i=0; i<100; i++) cout << i << " : " << rec[i] << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
int p[100010];
int d[100010]={};
int Top(int a){
  for(;p[a]-a;a=p[a]);
  return a;
}
int Find(int a,int b){
  int n,r;
  for(r=Top(a);p[a]!=a;a=n){
    n=p[a];
    p[a]=r;
  }
  for(r=Top(b);p[b]!=b;b=n){
    n=p[b];
    p[b]=r;
  }
  return a-b?1:0;
}
void Union(int a,int b){
  if(Find(a,b)){
    a=Top(a);
    b=Top(b);
    d[a]<d[b]?(p[a]=b):(p[b]=a);
    if(d[a]==d[b])d[a]++;
  }
}
int main(){
  int n,m,a,b,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)p[i]=i;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    Union(a-1,b-1);
  }
  for(i=a=0;i<n;i++){//printf("%d %d\n",i,Top(i));
    if(Top(i)==i)a++;
  }
  printf("%d\n",a-1);
  return 0;
}
    


Measured memory_bytes: 2508
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  int n[10];

  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 10; j++){
      scanf("%d", &n[j]);
    }
    sort(n, n + 10);
    printf("%d", n[9] + n[8] + n[7]);
    if (!i){
      printf(" ");
    }
    else {
      printf("\n");
    }
  }

  return (0);
}

Measured memory_bytes: 1208
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

long long int dp[100][10001], v[100], w[100];

int main()
{
	int N, W;

	cin >> N >> W;

	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (j < w[i])
			{
				dp[i][j] = i == 0 ? 0 : dp[i - 1][j];
			}
			else
			{
				dp[i][j] = i == 0 ? v[i] : max(dp[i - 1][j], v[i] + dp[i - 1][j - w[i]]);
			}
		}
	}

	cout << dp[N - 1][W] << endl;

	return 0;
}


Measured memory_bytes: 10900
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

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

  ll x = n/k;
  //cout<<"x:"<<x<<endl;;
  x = n - k*x;
  n = x;
  //cout<<"n:"<<n<<endl;

  ll min = n;

  while(1){
    n = abs(n - k);
    //cout<<n<<endl;
    if(min > n) min = n;
    if(min == n) break;
    //cout<<min<<endl;
  }
  cout<<min<<endl;

  
  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

char buf[20];

int main(void) {
  cin >> buf;
  int n = strlen(buf);
  int res = 100000000;
  REP(i, n-2) {
    int cur = (buf[i]-'0') * 100 + (buf[i+1]-'0') * 10 + (buf[i+2]-'0');
    if(abs(cur - 753) < abs(res - 753)) {
      res = cur;
    }
  }
  printf("%d\n", abs(res - 753));
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static int map[][];
	public static boolean used[][];
	public static int h, w;
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(System.in);
		while(true){
			w = in.nextInt();
			h = in.nextInt();
			if(w == 0) break;
			map = new int[h][w];
			used = new boolean[h][w];
			for(int i=0; i<h; i++){
				char[] s = in.next().toCharArray();
				for(int j=0; j<w; j++){
					map[i][j] = s[j]=='.'?0:s[j]-'0';
				}
			}
			Node res = null;
			for(int i=0; i<w; i++){
				if(map[h-1][i] == 0) continue;
				res = tree(map[h-1][i], h-1, i);
				break;
			}
			System.out.println(res==null?"UNSTABLE":"STABLE");
		}
	}
	public static int[] dx = {1, 0, -1, 0};
	public static int[] dy = {0, 1, 0, -1};
	public static Node tree(int id, int y, int x){
		Node node = new Node();
		Queue<Pos> qu = new LinkedList<Pos>();
		qu.add(new Pos(y, x));
		int lx = 200000;
		int rx = 0;
		int by = 0;
		double gx = 0;
		double gy = 0;
		while(!qu.isEmpty()){
			Pos p = qu.poll();
			if(used[p.y][p.x]) continue;
			int ux = p.x+dx[1];
			int uy = p.y+dy[1];
			if(uy == h || !out(uy, ux) && map[uy][ux]!=id){
				by = p.y;
				lx = Math.min(p.x, lx);
				rx = Math.max(rx, p.x);
			}
			gx += p.x+0.5;
			gy += p.y+0.5;
			used[p.y][p.x] = true;
			for(int i=0; i<4; i++){
				int ny = p.y+dy[i];
				int nx = p.x+dx[i];
				if(out(ny, nx)) continue;
//				if(map[ny][nx] == 0) continue;
				if(i==3 && map[ny][nx]!=id && !used[ny][nx]){
					Node v = tree(map[ny][nx], ny, nx);
					if(v == null) return null;
					node.createEdge(v);
					continue;
				}
				if(map[ny][nx] == id) qu.add(new Pos(ny, nx));
			}
		}
		node.x = gx/4.0;
		node.y = gy/4.0;
		if(isStable(node, lx, rx+1)) return node;
		return null;
	}
	
	public static boolean isStable(Node node, int lx, int rx){
		int block = 0;
		double gx = 0;
		double gy = 0;
		for(Node v: node.edge){
			block += v.block;
			gx += v.block*v.x;
			gy += v.block*v.y;
		}
		node.block += block;
		node.x = (node.x*4 + gx)/node.block;
		node.y = (node.y*4 + gy)/node.block;
		return lx < node.x && node.x < rx;
	}
	
	public static boolean out(int y, int x){
		return y < 0 || y >= h || x < 0 || x >= w || map[y][x] == 0;
	}
}

class Pos{
	int x, y;
	public Pos(int y, int x){
		this.x = x;
		this.y = y;
	}
}

class Node{
	double x, y;
	int block = 4;
	ArrayList<Node> edge = new ArrayList<Node>();
//	public Node(double y, double x){
//		this.x = x;
//		this.y = y;
//	}
	public void createEdge(Node nd){
		edge.add(nd);
	}
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  string s; cin >> s;
  ll r=0,g=0,b=0;
  for(int i = 0; i < n; ++i){
    if(s[i] == 'R')r++;
    if(s[i] == 'G')g++;
    if(s[i] == 'B')b++;
  }
  ll sum = r*g*b;
  debug(sum);
  for(int i = 1; i <= n/2; ++i){
    for(int j = 0; j <= n - i*2; ++j){
      if(j + i + i >= n) continue;
      if(s[j] != s[j+i] && s[j+i] != s[j+i+i] && s[j] != s[j+i+i]){
	sum--;	
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = b[i] = x;
  }
  
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < n; i++) cout << (b[i] == a[0] ? a[1] : a[0]) << endl;
}

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

constexpr int inf = 1e9;

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < C; ++j) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(N, vector<int>(N));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> c[i][j];
        }
    }
    vector<vector<int>> cost(3, vector<int>(C));
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < C; ++j) {
            for(int y = 0; y < N; ++y) {
                for(int x = 0; x < N; ++x) {
                    if((y + x) % 3 == i) {
                        cost[i][j] += D[c[y][x] - 1][j];
                    }
                }
            }
        }
    }
    int ans = inf;
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < C; ++j) {
            for(int k = 0; k < C; ++k) {
                if(i == j || j == k || i == k) continue;
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
my$n=+get;
my@R=sort -*.[1],(+<<get.words)xx $n;
my$B=+<<lines>>.words;
say +grep {my$i=@R.first({.[0]>$^a[0]&&.[1]>$^a[1]},:k);$i.isa(Int)&&(@R[$i]=3e2)},$B.sort

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end(), greater<int>());

    int ans = 0;
    rep(i, K) ans += L[i];

    cout << ans << endl;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << " " << x.s << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n, r; cin >> n >> r;

    if(n >= 10) cout << r;
    else cout << r + 100*(10 - n);
}	

Measured memory_bytes: 3652
def main():
    mod = 10**9+7
    n=int(input())
    a=list(map(int,input().split()))

    flag = [0 for _ in range(100000)]
    res = 1
    for i in range(n):
        ta =  a[i]
        if ta == 0:
            res *= 3 - flag[0]
            res %= mod
        else:
            fta1 = flag[ta-1]
            fta = flag[ta]
            if fta1 == 0:
                return 0
            res *= fta1 - fta
            res %= mod
        flag[ta] += 1
        if flag[a[i]] > 3:
            return 0
    return res 

print(main())

Measured memory_bytes: 56024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <utility>

using namespace std;

class Restaurant {
  public:
    string city;
    int score;
    int id;
    Restaurant(int _id, int _score, string _city) { id = _id; score = _score; city = _city; }
};

bool has_smaller_string(const string& a, const string& b)
{
  for (int i = 0; i < (int)a.size() && i < (int)b.size(); i++) {
    if (a.at(i) < b.at(i)) {
      return true;
    }
    if (a.at(i) > b.at(i)) {
      return false;
    }
  }
  return a.size() < b.size();
}

bool has_smaller_city_name(const Restaurant& a, const Restaurant& b)
{
  return has_smaller_string(a.city, b.city);
}

bool has_higher_score(const Restaurant& a, const Restaurant& b)
{
  return a.score > b.score;
}

int main()
{
  int n;
  cin >> n;
  vector<Restaurant> restaurant;
  for (int i = 0; i < n; i++) {
    int v;
    string s;
    cin >> s >> v;
    restaurant.emplace_back(i+1, v, s);
  }
  sort(restaurant.begin(), restaurant.end(), has_higher_score);
  stable_sort(restaurant.begin(), restaurant.end(), has_smaller_city_name);
  for (const auto& r : restaurant) {
    cout << r.id << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 101000;

int n, f[N][61];

struct Edge
{
    int nxt, to;
} eg[N << 1];
int head[N], en;

void setEdge(int u, int v)
{
    eg[++en] = (Edge) {head[u], v};
    head[u] = en;
}

void dfs(int u, int fa)
{
    for (int e = head[u]; e; e = eg[e].nxt)
    {
        int v = eg[e].to;
        if (v == fa) continue;
        dfs(v, u);
        for (int i = 0; i <= 60; i++)
            f[u][i] += f[v][i];
    }
    for (int i = 60; i >= 0; i--)
        if (f[u][i] > 1)
        {
            int p = i + 1;
            while (f[u][p]) p++;
            f[u][p] = 1;
            for (int j = 0; j < p; j++)
                f[u][j] = 0;
            return ;
        }
    int p = 0;
    while (f[u][p]) p++;
    f[u][p] = 1;
    for (int j = 0; j < p; j++)
        f[u][j] = 0;
}

int main()
{
    n = read();
    for (int i = 1; i < n; i++)
    {
        int u = read(), v = read();
        setEdge(u, v);
        setEdge(v, u);
    }
    dfs(1, 0);
    for (int i = 60; i >= 0; i--)
        if (f[1][i])
        {
            printf("%d\n", i);
            return 0;
        }
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    int a,b,k;cin>>a>>b>>k;
    for(int i=a;i<=b;i++){
        if(i<a+k||i>b-k) cout << i << endl;
    }
    return 0;
}


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

int main()
{
    int n;cin>>n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    int count2=0;
    int count4=0;
    for(i=0;i<n;i++)
    {
        if(a.at(i)%4==0)count4++;
        else if(a.at(i)%2==0)count2++;
    }
    if(count4*2+max(count2-1,0)>=n-1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (((x + r) <= W && (x - r) >= 0) && ((y + r) <= H && (y - r) >= 0))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int x;cin>>x;
  int ans=0;
  ans+=(x/500)*1000;
  x%=500;
  ans+=(x/5)*5;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
int main(int argc, char** argv) {
	string s;
	cin>>s;
	int ans=0;
	int lst=0;
	char ls='?';//3  2  2   1 
	rep(i,0,s.length()-1)
	{
		int j=i;
		while(s[j]==s[i])
		{
			j++;
		}
		if((j-i-lst)%3<=1)
		{
			ans+=(j-i-lst)/3;
		
			//cout<<(j-i-lst)<<"?"<<endl;
			lst=0;
		}
		else
		{
			
			ans+=(j-i-lst)/3+1;
		//	if((j-i-lst)/3+1)
			//cout<<(j-i-lst)<<endl;
			//cout<<j<<" "<<i<<endl;
			lst=1;
		}
		i=j-1;
	}
	ans=s.length()-ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N;

int main(){
	cin>>N;
	vector<LL>v;
	v.push_back(N);
	if(N!=2){
		v.push_back(N-1);
	}
	vector<LL>w;
	REP(i,min((LL)1000010,N-1)){
		if(i==0)continue;
		if(i==1)continue;
		LL temp=N;
		if(temp%i==0){
			w.push_back(temp/i);
		}
		while(i<=temp){
			//cout<<temp<<" aaa"<<endl;
			if(temp%i==0){
				temp/=i;
			}else{
				temp=temp%i;
			}
		}
		//cout<<"temp"<<temp<<endl;
		//cout<<endl;
		if(temp==1){
			v.push_back(i);
		}
	}
	REP(i,w.size()){
		LL temp=N;
		while(w[i]<=temp){
			//cout<<temp<<" aaa"<<endl;
			if(temp%w[i]==0){
				temp/=w[i];
			}else{
				temp=temp%w[i];
			}
		}
		//cout<<"temp"<<temp<<endl;
		//cout<<endl;
		if(temp==1){
			v.push_back(w[i]);
		}
	}
	LL M=N-1;
	REP(i,min((LL)1000010,M)){
		if(i==0)continue;
		if(i==1)continue;
		LL temp=M;
		if(temp%i==0){
			w.push_back(temp/i);
		}
	}
	REP(i,w.size()){
		LL temp=N;
		if(w[i]<2)continue;
		while(w[i]<=temp){
			//cout<<temp<<" aaa"<<endl;
			if(temp%w[i]==0){
				temp/=w[i];
			}else{
				temp=temp%w[i];
			}
		}
		//cout<<"temp"<<temp<<endl;
		//cout<<endl;
		if(temp==1){
			v.push_back(w[i]);
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	/*REP(i,v.size()){
		cout<<v[i]<<endl;
	}*/
	cout<<v.size()<<endl;
}

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

using namespace std;

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

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

    cin >> a >> b >> k;

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

    cout << v[v.size() - k];

    return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<ll> L(n);
   rep(i,n) cin >> L[i];
   ll ans = 0;
   for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
         for(int k=j+1;k<n;k++){
            if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] &&L[k]+L[j]>L[i] && L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]){
               ans++;
            }
         }
      }
   }
   cout << ans << endl;
   return 0;  
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,ans1,ans2,ans3=1145141919,p,o;
string s;

int  main(){
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='.'){ans1++;p++;}
        if(s[i]=='#'){ans2++;}
    }

    for(int i=0;i<n;i++){
        if(s[i]=='#')o++;
        if(s[i]=='.'){ans3=min(ans3,p-1+o);p--;}
    }


    cout<<min(ans1,min(ans2,ans3))<<endl;

}




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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n, m;
VS grid;
VS solve()
{
	VS ans(n * 2, string(m, ' '));

	for(int i = 0; i < 2 * n; ++i)
		for(int j = 0; j < m; ++j)
			ans[i][j] = grid[i / 2][j];
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> m;

	grid = VS(n);
	REP(i, 0, n) cin >> grid[i];

	for(auto str : solve())
		cout << str << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define in insert
#define mk make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(a) a.begin(), a.end()
#define INF (1<<28)
typedef long long int ll; typedef long int l; typedef pair<int, int> pii;
const double PI = acos(-1);
ll dp[100005];

void initialize(){
    for(int i=0;i<100005;i++)dp[i] = 999999999999;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    int arr[100005];
    for(int i=0;i<n;i++)cin>>arr[i];

    initialize();
    dp[0] = 0;
    for(int i=0;i<n-1;i++){
        if(i+1 < n)dp[i+1] = min(dp[i+1], dp[i]+ abs(arr[i+1]-arr[i]));
        if(i+2 < n)dp[i+2] = min(dp[i+2], dp[i]+ abs(arr[i+2]-arr[i]));
    }
    // for(int i=0;i<n;i++){
    //     cout<<dp[i]<<endl;
    // }
    cout<<dp[n-1]<<endl;
return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
	long long n,t,last = 0,a;
	long long sol = 0;
	
	cin >> n >> t;

	for(int i = 0;i < n;i++)
	{
		cin >> a;
		
		if(a < last+t && i != 0)
			sol-=last+t-a;
		
		sol+=t;
		
		last = a;
	}
	cout << sol << endl;
	return 0;
}

Measured memory_bytes: 384