akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
using namespace std;
const int MAXN = 1e5+5;
int dp[MAXN][3];
inline int max(int a,int b){
    return a>b?a:b;
}
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;++i)
        for(int j=0;j<3;++j)
            cin>>dp[i][j];
    for(int i=1;i<N;++i){
        for(int j=0;j<3;++j){
            dp[i][j]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    int maxx=0;
    for(int i=0;i<3;++i)
        maxx=max(maxx,dp[N-1][i]);
    cout<<maxx<<endl;
    return 0;
}

Measured memory_bytes: 1408
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/09/20 20:58:21
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n;
  cin>>n;
//  n =  3;
  vector<string> S(n);
  for (auto& s:S) cin>>s;

  vector<map<int, int>> trie(1);
  vector<bool> leaf(1);
  for (auto& s:S) {
    int id = 0;
    for (auto it = s.rbegin(); it != s.rend(); ++it) {
      if (trie[id].count(*it) == 0) {
        auto nx = trie.size();
        trie[id][*it] = nx;
        id = nx;
        trie.emplace_back();
        leaf.push_back(false);
      } else {
        id = trie[id][*it];
      }
    }
    leaf[id] = true;
  }
  vector<array<int, 26>> chs(trie.size());
  auto dfs = [&chs, &trie, &leaf](auto& f, int s) -> int {
    int sz = leaf[s];
    for (auto [c, t]:trie[s]) {
      int csz = f(f, t);
      sz += csz;
      for (int i = 0; i < 26; i++) {
        if (i != c-'a')
          chs[s][i] += chs[t][i];
        else
          chs[s][i] += csz;
//        cerr<<chs[s][i]<<endl;
      }
    }
//    cerr<<sz<<endl;
    return sz;
  };
  dfs(dfs, 0);

  ll ans = 0;
  for (auto& s:S) {
    int id = 0;
    for (int i = s.size()-1; i > 0; i--) {
      assert(trie[id].count(s[i]) > 0);
      id = trie[id][s[i]];
    }
    ans += chs[id][s[0]-'a']-1;
//    cerr<<chs[id][s[0]-'a']<<endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 273332
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in(),C=in();

	out((A+B+C)>=22?"bust":"win");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long x,k,d;
    cin >> x >> k >> d;

    if(abs(x) / d <= k){
        long long a = abs(x) % d;
        if( (k - abs(x) / d) % 2 == 0 ){
            cout << a << endl;
        }else{
            cout << min(abs(a + d),abs(a - d)) << endl;
        }
    }else{
        cout << abs(abs(x) - k * d) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

// (x, y) を始点とした BFS をして、(x, y) から最も遠いマスへの距離を答える
int bfs(const vector<string> &v, ll x, ll y) {
    ll H = v.size(), W = v[0].size();
    vvl dist(H, vl(W, -1));//-1で埋める
    queue<pair<ll,ll>> que;

    ll res = 0;
    que.push(make_pair(x,y));
    dist[x][y] = 0;
    while (!que.empty()) {
        ll x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        rep(dir,4){
            ll nx = x+ dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '.'&&dist[nx][ny]==-1){ //未探索の道なら
                dist[nx][ny] = dist[x][y] + 1; //前のマス+1
                que.push({nx, ny}); //4方位をqueueに追加
            }
        }
    }
    return res;
}

int main() {
     SS(ll,k,x)
     ll a=1;
     rep(i,k)a*=500;
     a>=x?p("Yes"):p("No");
}

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

int main(){
    vector<int> num(3);
    cin>>num[0]>>num[1]>>num[2];

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

    cout<<num[2] * 10 + num[1] + num[0] <<endl;

    return 0;
    
}

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

const ll mod = 1000000007;

ll fact(ll n){
  if(n>1)
  return n%mod*fact(n-1)%mod;
  else
  return 1;
}
int main(){
  ll N;
  cin>>N;
  cout<<fact(N)<<endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
h, w, k = map(int, input().split())
k = []
for i in range(h):
    s = input()
    k.append(s)
ans = []
c = 0
for i in range(h):
    f = 0
    r = []
    if "#" in k[i]:
        c+=1
        for j in range(w):
            if k[i][j] == "#":
                if f:
                    c += 1
                else:
                    f = 1
            r.append(str(c))
    ans.append(r)

pre = ""
for i in range(h):
    if ans[i]:
        pre = ans[i]
    elif pre:
        ans[i] = pre
pre = ""
for i in reversed(range(h)):
    if ans[i]:
        pre = ans[i]
    elif pre:
        ans[i] = pre

for item in ans:
    print(" ".join(item))


Measured memory_bytes: 45808
#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    unordered_map<string, int> dict;
    int n;
    cin >> n;
    int res = 0;
    while(n --){
        string str;
        cin >> str;
        dict[str] ++;
        res = max(res, dict[str]);
    }
    vector<string> ans;
    for(auto it = dict.begin(); it != dict.end(); it ++){
        if(it->second == res){
            ans.push_back(it->first);
        }
    }
    sort(ans.begin(), ans.end());
    for(auto j: ans){
        cout << j << endl;
    }
    return 0;
}

Measured memory_bytes: 22132
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let a = scanner.ArrayI32(n)
    let mutable f = 0
    let mutable d = 0
    let mutable c = 0
    a
    |> List.iter (function
        | x when x % 4 = 0 -> f <- f + 1
        | x when x % 2 = 0 -> d <- d + 1
        | x -> c <- c + 1
    )
    let c = if d > 0 then c + 1 else c

    if f > c-2 then "Yes" else "No"
    |> printfn "%s"

    0


Measured memory_bytes: 27352
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P>> Graph;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vector<int> b = a;
  sort(b.begin(),b.end());


  map<int,int> mp,mp2;
  REP(i,n){
    if(i%2 == 0) continue;
    mp2[a[i]]++;
    mp[b[i]]++;
  }

  int ans = 0;
  ITR(itr,mp){
    ans += min(itr->sc,mp2[itr->fs]);
  }

  cout << n/2 - ans << endl;

  return 0;
}

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

typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair

const int MAXN = 100;
const int MOD = int(1E9) + 7;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return 1LL * x * y % MOD;}

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=mul(b,b))
		if( i & 1 ) ret = mul(ret, b);
	return ret;
}

int h[MAXN + 5], N;
pii get(int l, int r, int lh) {
	int mn = h[l];
	for(int i=l;i<=r;i++)
		mn = min(mn, h[i]);
	
	int lst = l; pii ret = mp(1, 1);
	for(int i=l;i<=r;i++) {
		if( h[i] == mn ) {
			if( i > lst ) {
				pii tmp = get(lst, i - 1, mn);
				ret.fi = mul(ret.fi, tmp.fi);
				ret.se = mul(ret.se, add(mul(2, tmp.fi), tmp.se));
			}
			ret.se = mul(ret.se, 2);
			
			lst = i + 1;
		}
	}
	if( r >= lst ) {
		pii tmp = get(lst, r, mn);
		ret.fi = mul(ret.fi, tmp.fi);
		ret.se = mul(ret.se, add(mul(2, tmp.fi), tmp.se));
	}
	
	return mp(mul(ret.fi, pow_mod(2, mn - lh)), sub(ret.se, mul(2, ret.fi)));
}

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", &h[i]);
	
	pii k = get(1, N, 0);
	printf("%d\n", add(k.fi, k.se));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;

struct cake {
	long long x;
	long long y;
	long long z;
};


unsigned char plusminus;
bool cakesort(const cake& x, const cake& y)
{
	int xplus = ((plusminus & 0x4) == 0x4) ? 1 : -1;
	int yplus = ((plusminus & 0x2) == 0x2) ? 1 : -1;
	int zplus = ((plusminus & 0x1) == 0x1) ? 1 : -1;

	long long xsum = x.x*xplus + x.y*yplus + x.z*zplus;
	long long ysum = y.x*xplus + y.y*yplus + y.z*zplus;

	return xsum > ysum;
}


int main(void)
{
	int N, M;
	cin >> N >> M;

	vector <cake> cakes;
	for (int i = 0; i < N; i++) {
		cake input;
		cin >>input.x >> input.y >> input.z;
		cakes.push_back(input);
	}

	unsigned long long ans = 0;
	for (unsigned char i = 0; i <= 0x7; i++) {
		plusminus = i;
		std::sort(cakes.begin(), cakes.end(), cakesort);

		long long sum[3] = {0};
		for (unsigned int j = 0; j < M; j++) {
			sum[0] += cakes.at(j).x;
			sum[1] += cakes.at(j).y;
			sum[2] += cakes.at(j).z;
		}
		unsigned long long tmpans = abs(sum[0]) + abs(sum[1]) + abs(sum[2]);
		ans = std::max(ans, tmpans);
	}

	cout << ans << endl;

	return 0;
}


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

ll gcd(ll a, ll b) {
  if (a<b) swap(a,b);
  while (1) {
    if (a%b == 0) return b;
    ll r = a%b;
    a = b;
    b = r;
  }
}

ll lcm(ll a, ll b) {
  return a / gcd(a,b) * b;
}

int main() {
  ll N, M;
  string s, t;
  cin >> N >> M >> s >> t;
  ll g = gcd(N,M);
  ll L = lcm(N,M);
  bool b = true;
  
  ll n = N/g;
  ll m = M/g;
  for (ll i = 0; i < g; i++) {
    if (s[i*n] != t[i*m]) b = false;
  }
  cout << (b ? L : -1) << endl;
}

Measured memory_bytes: 512
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int n,k,ans=0;
    cin >> n >> k;
    int tmp;
    REP(i,n){
        cin >> tmp;
        ans+= 2* min(abs(tmp - k), tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,k,i,a[100000],m,u,s;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==1){u=i;}
}
m=(n-1)-u;
s+=m/(k-1);
s+=u/(k-1);
if((m%(k-1))+(u%(k-1))>k-1){s+=2;}
else if((m%(k-1))+(u%(k-1))==0){s+=0;}
else{s+=1;}
printf("%d",s);

return 0;


}

Measured memory_bytes: 512
S = input()
T = input()

ans = len(T)+1
for start in range(len(S)-len(T)+1):
    #print("start", start)
    diff = 0
    for offset in range(len(T)):
        #print(start+offset, offset)
        if S[start+offset] != T[offset]:
            diff += 1
    ans = min(diff, ans)

print(ans)

Measured memory_bytes: 73320
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int LOG = 65;
const LL MOD = 1000000007;
const LL INF = (LL) 1e9 + 5;

LL L, R, dp[LOG][2][2][2];
bool vis[LOG][2][2][2];
vector<int> d1, d2;

void trans(LL x, vector<int> &d) {
	d.clear();
	for (int i = 0; i < LOG; i++) {
		d.push_back(x % 2);
		x /= 2;
	}
//	cout << "Get:"; for (int x : d) cout << x; cout << '\n';
}

LL dfs(int pos, bool lim1, bool lim2, bool first) {
	if (pos < 0) return 1;
	if (vis[pos][lim1][lim2][first]) return dp[pos][lim1][lim2][first];
	vis[pos][lim1][lim2][first] = true;
	
	int up1 = lim1 ? d1[pos] : 1;
	LL res = 0;
	for (int i = 0; i <= up1; i++) {
		int up2 = lim2 ? min(d2[pos], i) : i;
		for (int j = 0; j <= up2; j++) {
			if (first && i == 1 && j == 0) continue;
			res = (res + dfs(pos - 1, lim1 && i == d1[pos], lim2 && j == d2[pos], first && i == 0)) % MOD;
		}
	}
	
	return dp[pos][lim1][lim2][first] = res;
}

LL solve(LL r1, LL r2) {
	trans(r1, d1);
	trans(r2, d2);
	memset(vis, 0, sizeof(vis));
	return dfs((int) d1.size() - 1, 1, 1, 1);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> L >> R;
	cout << (solve(R, R) - solve(R, L - 1) + MOD) % MOD << '\n';
	
//	LL bf = 0;
//	for (LL i = L; i <= R; i++) {
//		for (LL j = L; j <= R; j++) {
//			int m1 = 0, m2 = 0, t1 = i, t2 = j;
//			while (t1) t1 >>= 1, m1++;
//			while (t2) t2 >>= 1, m2++;
//			if (m1 != m2) continue;
//			if ((i | j) == i) bf++;
//		}
//	}
//	cout << "BF say " << bf << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char a,b;
	scanf("%c %c", &a,&b);
	if (a > b)
	{
		printf(">");
	}

	else if (a < b)
	{
		printf("<");
	}
	else
	{
		printf("=");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<pair<double,double>> g(n);

  rep(i,n) cin >> g[i].first >> g[i].second;

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

  double tot = 0;
  do{
    rep(i,n){
      if(i == n-1) continue;
        double nx = g[i+1].first;
        double ny = g[i+1].second;
        double x = g[i].first;
        double y = g[i].second;
        tot += sqrt((nx-x)*(nx-x)+(ny-y)*(ny-y));
    }
  }while(next_permutation(g.begin(),g.end()));
  
  double div = 1;
  for(int i = 1; i <=n; i++) div *= i;

  printf("%f10\n", tot/div);
}


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

int main(){
    int N, ans=0, a, b;
    cin >> a >> b;
    for(int i=0; i<=a; i++){
	for(int j=0; j<=a; j++){
	    if( b-(i+j) >=0 && b-(i+j) <= a){
		ans ++;
	    }
	}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
base = 1
pos = 0
ans = ''
while N != 0:
    if abs(N) & (1 << pos):
        N -= base
        ans += '1'
    else:
        ans += '0'
    pos += 1
    base *= -2
# corner case!
if ans == '':
    print(0)
else:
    print(ans[::-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll nCm[NUM][NUM];
ll fact[NUM];
ll memo[NUM];
ll POW[NUM];

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll &e){
	e = 0;
	if(n == 0)return 1;

	int res = mod_fact(n/p,p,e);
	e += n/p;

	if(n/p%2 != 0)return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	fact[0] = 1;
	for(ll i = 1; i <= K; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}

	//数字^Nを求める
	POW[0] = 1;
	ll tmp;
	for(ll i = 1; i <= K; i++){
		tmp = 1;
		for(int loop = 0; loop < N; loop++){
			tmp *= i;
			tmp %= MOD;
		}
		POW[i] = tmp;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++){
		for(int m = 0; m <= K; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	memo[1] = 1;

	for(ll num = 2; num <= K-1; num++){

		memo[num] = POW[num];

		for(int i = 1; i <= num-1; i++){
			memo[num] -= nCm[num][i]*memo[i];
			memo[num] %= MOD;
			if(memo[num] < 0)memo[num] += MOD;
		}
	}

	ll ans = POW[K];

	for(int i = 1; i <= K-1; i++){

		ans -= nCm[K][i]*memo[i];
		ans %= MOD;
		if(ans < 0)ans += MOD;
	}

	ans *= mod_inverse(fact[K],MOD);
	ans %= MOD;
	if(ans < 0)ans += MOD;

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

	return 0;
}



Measured memory_bytes: 11028
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

struct Card{
    char suit, value;
};

void bubble(struct Card A[], int n){
    rep(i, n){
        for(int j = n - 1; j >= 0; j--){
            if(A[j].value < A[j - 1].value){
                Card g = A[j];
                A[j] = A[j - 1];
                A[j - 1] = g;
            }
        }
    }
}

void selection(struct Card A[], int n){
    int minj;
    rep(i, n){
        minj = i;
        range(j, i, n){
            if(A[j].value < A[minj].value){
                minj = j;
            }
        }
        Card g = A[i];
        A[i] = A[minj];
        A[minj] = g;
    }
}

void print(struct Card A[], int n){
    rep(i, n){
        if(!i) cout << A[i].suit << A[i].value;
        else cout << ' ' << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card c1[], struct Card c2[], int n){
    rep(i, n){
        if(c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

int main(){
    int n;
    while(cin >> n){
        Card c1[100], c2[100];
        rep(i ,n){
            cin >> c1[i].suit >> c1[i].value;
            c2[i] = c1[i];
        }

        bubble(c1, n);
        selection(c2, n);

        print(c1, n);
        cout << "Stable" << endl;
        print(c2, n);
        if(isStable(c1, c2, n)){
            cout << "Stable" << endl;
        }else{
            cout << "Not stable" << endl;
        }
    }
}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll a=in(),b=in(),c=in();
    cout<<max(0LL,c-(a-b))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>
#include<iomanip>
#include<set>


using namespace std;

int a[10][4]={{0,0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
int main(){


	
	while(1){
	string p;
	cin>>p;if(p=="0")return 0;

	int Y[15]={};
	for(int i=1;i<p.size();i++){
		if(p[i]>='0'&&p[i]<='9')Y[i]=p[i]-'0';
		else {Y[i]=10;Y[i]+=p[i]-'a';
		}
	}
	int X[5]={};
	for(int i=0;i<3;i++){
		X[i]+=16*Y[2*i+1];
		X[i]+=Y[2*i+2];
	}
	double ans=0,Bst=9999999;
	int k=0;
	double c0=X[0],c1=X[1],c2=X[2];
	for(int i=0;i<8;i++){
		double A=a[i][0]-c0,B=a[i][1]-c1,C=a[i][2]-c2;
		
		ans=sqrt(A*A+B*B+C*C);

		if(ans<Bst){Bst=ans;k=i;}
	}
	if(k==7)cout<<"white"<<endl;
	else if(k==6)cout<<"yellow"<<endl;
	else if(k==5)cout<<"fuchsia"<<endl;
	else if(k==4)cout<<"red"<<endl;
	else if(k==3)cout<<"aqua"<<endl;
	else if(k==2)cout<<"lime"<<endl;
	else if(k==1)cout<<"blue"<<endl;
	else if(k==0)cout<<"black"<<endl;

	}
	}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#define NMAX 3000

using namespace std;

int dp[NMAX+10][NMAX+10];
string s1, t1;
char s[NMAX+10], t[NMAX+10];
vector <char> sol;

int main()
{
    cin >> s1 >> t1;
    int n = s1.size(), m = t1.size();
    for(int i=0; i<n; i++) s[i+1] = s1[i];
    for(int i=0; i<m; i++) t[i+1] = t1[i];
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            {   if(s[i] == t[j]) dp[i][j] = 1 + dp[i-1][j-1];
                else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
    int i = n, j = m;
    while(i && j)
        {   if(s[i] == t[j]) sol.push_back(s[i]), i--, j--;
            else
                {   if(dp[i-1][j] >= dp[i][j-1]) i--;
                    else j--;
                }
        }
    for(int i=sol.size()-1; i>=0; i--) cout << sol[i];
    cout << '\n';
    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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

    ll d = 0;
    if(2 <= b-a) d = b-a;

    ll t = 0;
    ll bis = 1;
    if(k <= a-1) bis += k, t += k;
    else         bis += a-1, t += a-1;
    if(2 <= d){
        while(t < k-1) bis+=d, t+=2;
    }
    
    bis += k-t;
    t += k-t;
    
    cout << bis << endl;

    return 0;
}



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

int main() {
  int r; cin >> r;
  cout << r * r << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scanln(&s)

  var l int = -1
  var r int

  for i := 0; i < len(s); i++ {
    if s[i] == 'A' && l == -1 {
      l = i
    }
    if s[i] == 'Z' {
      r = i
    }
  }

  fmt.Println(r - l + 1)
}

Measured memory_bytes: 2048
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 3000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
} f;

int dp[3001];
int A[3001], B[3001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N, S;
	scanf("%d %d", &N, &S);

	rep(i, N) {
		int a;
		scanf("%d", &a);
		A[a]++;
	}

	ll k2 = modpow(2, mod - 2);
	dp[0] = modpow(2, N);
	int s = A[1];
	ll kotae1 = 0, kotae2 = 0;
	B[0] = 1;

	rep1(b, A[1]) {
		if (b > S) break;
		dp[b] = k2 * dp[b - 1] % mod * (A[1] - b + 1) % mod * f.inv[b] % mod;
	}
	kotae2 = dp[S];

	for (int a = 2; a <= S; a++) {
		if (A[a] == 1) {
			s = min(S - a - 1, s + a);
			if (S >= a) kotae1 += dp[S - a];
			for (int j = s; j >= a; j--) {
				dp[j] = (dp[j] + dp[j - a] * k2) % mod;
			}
		}
		else if (A[a]) {
			rep1(b, A[a]) {
				B[b] = k2 * B[b - 1] % mod * (A[a] - b + 1) % mod * f.inv[b] % mod;
			}

			s = min(S - a, s + a * A[a]);
			if (S >= a) {
				rep1(b, A[a]) {
					if (S - a * b < 0) break;
					kotae2 += ll(dp[S - a * b]) * B[b] % mod;
				}
			}
			for (int j = s; j >= a; j--) {
				ll tmp = dp[j];
				rep1(b, A[a]) {
					if (j - a * b < 0) break;
					tmp += ll(dp[j - a * b]) * B[b] % mod;
				}
				dp[j] = tmp % mod;
			}
		}
	}

	printf("%lld\n", (kotae1 % mod * k2 + kotae2) % mod);

	Would you please return 0;
}

Measured memory_bytes: 1792
import numpy as np

L, R = map(int, input().split())
MOD = 2019

# if L == R:
#     tmp = L % MOD
#     print(tmp*tmp)
# else:
#     a = np.array(range(L, R+1)) % MOD
#     b = np.sort(a,kind='quicksort')
#     print(b[0]*b[1])

minMOD = 2019
# minMOD2 = 2019
#
# for i in range(L, R+1):
#     tmp = i % MOD
#     if tmp == 0:
#         minMOD = 0
#         break
#
#     if tmp < minMOD:
#         minMOD = tmp
#     elif tmp < minMOD2:
#         minMOD2 = tmp

#print((minMOD * minMOD2) % MOD)

for i in range(L, R+1):
    if(i % MOD) == 0:
        minMOD = 0
        break
    for j in range(i+1, R+1):
        if(j % MOD) == 0:
            minMOD = 0
            break
        tmp = (i*j)%MOD
        if tmp < minMOD:
            minMOD = tmp
            if(tmp == 0):
                break

print(minMOD)


Measured memory_bytes: 14532
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    int ans = -1;
    double diff = 9999999;
    for (int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        double t = T - h * 0.006;
        double d = abs((double)A - t);
        if (d < diff) {
            ans = i + 1;
            diff = d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans=1e18;
signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(all(a));
	int x=(a[n-1]+1)/2;
	for(int i=0;i+1<n;i++)
		if(abs(x-a[i])<abs(x-ans))
			ans=a[i];
	cout<<a[n-1]<<' '<<ans;
	re 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    dump(s == "AAA" or s == "BBB" ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
  
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
 
template <class X> void print(X Target){ cout << Target << '\n'; }

signed main()
{
  ios::sync_with_stdio(false);
  int L;
  
  while (cin >> L, L){
    int sum = 0, ans = 0;
    for (int i = 0; i < 12; i++){
      int M, N;
      cin >> M >> N;
      sum += M - N;
      if (!ans && sum >= L){
        ans = i + 1;
      }
    }
    if (ans){
      print(ans);
    }
    else {
      print("NA");
    }
  }

  return (0);
}

Measured memory_bytes: 1196
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;



int main() {
    ll n;
    cin >> n;
    ll prev = 0;
    ll continuous = 0;
    ll count = 0;
    for (auto i = 0; i < n; i++) {
        ll cur;
        cin >> cur;
        if (cur != prev)
            continuous = 0;
        ++continuous;
        if (continuous % 2 == 0)
            count++;
        prev = cur;
    }
    cout << count << endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<ll,ll>ch;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ch[x]++;
	}
	ll cnt=1;
	while(cnt<2'000'000'000){
		cnt*=2;
	}
	ll ans=0;
	while(ch.size()!=0){
		auto itr=ch.end();
		itr--;
		ll now=itr->first;
		ch[now]--;
		if(itr->second==0){
			ch.erase(now);
		}
		if(ch.size()==0){
			break;
		}
		while(now<cnt/2){
			cnt/=2;
		}
		auto ser=ch.find(cnt-now);
		if(ser!=ch.end()){
			ch[cnt-now]--;
			ans++;
			if(ser->second==0){
				ch.erase(cnt-now);
			}
		}
	}
	cout <<ans;

	// your code goes here
	return 0;
}

Measured memory_bytes: 12800
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    X, K, D = mi()

    if X < 0:
        n = -X // D
        if n >= K:
            print(abs(X+K*D))
            return
        print(abs(X+(n+(K-n)%2)*D))
    else:
        n = X // D
        if n >= K:
            print(abs(X-K*D))
            return
        print(abs(X-(n+(K-n)%2)*D))


if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[111111], cnt[111111], l = -1, r, m;
ll g[111111], o[111111], ng[30], x, y, ans;

ll comb(ll N, ll R) {
	if (N<0 || R<0 || N<R) return 0;
	if (N==0 && R==0) return 1;
	return o[N] * g[R] % mod * g[N-R] % mod;
}

int main() {
	cin >> n;
	rep(i,n+1) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]]==2) m = a[i];
	}
	
	// 重複要素2つのインデックス(l<r)を取得
	rep(i,n+1) {
		if (a[i]==m) {
			if (l==-1) l = i+1;
			else r = i+1;
		}
	}
	
	// 事前に分子の方(n!)を全通り 100001!まで
	o[0] = o[1] = 1;
	repst(i,2,100001) o[i] = o[i-1] * i % mod;
	// フェルマーの小定理でまず(100001!)^-1を求めて、それに100001をかけると(100000!)^-1が求められる
	// これを繰り返すことで高速に逆元テーブルを作れる
	// 1〜n+1の逆元テーブルを全部作っておけば後で全てのnCkがO(1)で計算できる
	// ng[i]: 100001!の2^i乗 繰り返し2乗法
	ng[0] = o[100001];
	reps(i,1,30) ng[i] = ng[i-1] * ng[i-1] % mod;
	// 100001!のmod-2乗 == -1乗(%mod)を求める
	g[100001] = 1;
	rep(i,30) if ((mod-2)>>i & 1) g[100001] = g[100001] * ng[i] % mod;
	// さっき言った方法を使って上から順に逆元テーブルを埋める
	repr(i,100000) g[i] = g[i+1] * (i+1) % mod;
	
	// まず(n+1)Ckが重複を許した場合の部分列の個数 ここから重複した部分列の個数を引きたい
	// 公式解説の通り、重複する部分列ってのはその部分列の数字がそれぞれ元の数列のどこに対応するかわからないもの
	// a[l]とa[r]のうち片方だけと、lとrに挟まれていない部分も使っている部分列は復元できない
	// 例えば23145167って数列から取り出せる21とか167って部分列の"1"はどっちの1を使っているのかわからない ∴ 重複する
	// こういう部分列の数は、a[l]かa[r]を1個 と 範囲[l,r]に含まれないl-1 + n+1-r個の要素からk-1個 選ぶ組み合わせの個数に等しい
	repst(k,1,n+1) {
		//cout << l << "番目の左側" << l-1 << "個と、" << r << "番目の右側" << n+1-r << "個の中から" << k-1 << "個選ぶ" << ln;
		// n+1 C k
		x = comb(n+1, k);
		// (l-1 + n+1-r) C k-1
		y = comb(l+n-r, k-1);
		// 負にならないようにmod足してから引き算
		ans = (x + mod - y) % mod;
		cout << ans << ln;
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 = 1e18;


int main(){
    string s,t;
    cin >> s >> t;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3628
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	for i := 0; i < N; i++ {
		a := getInt()
		if a%2 != 0 {
			out("first")
			return
		}
	}
	out("second")
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    int C=in();
    int ans;
    if(A==B&&B==C){
        if(A%2==0){
            ans=-1;
        }else{
            ans=0;
        }
        print(ans);
        return 0;
    }
    ll temp_val;
    for(int i=0;i<1e9;i++){
        if(A%2!=0||B%2!=0||C%2!=0){
            ans=i;
            print(ans);
            return 0;
        }
        temp_val=(A+B+C)/2;
        A=temp_val-(A/2);
        B=temp_val-(B/2);
        C=temp_val-(C/2);
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

type task struct {
	time int
	end int
}

type tasks []task

func (t tasks) Len() int {return len(t)}
func (t tasks) Swap(i,j int) { t[i], t[j]=t[j], t[i] }
func (t tasks) Less(i,j int) bool { return t[i].end < t[j].end }

func main() {
	var n, t1, t2 int
	fmt.Scan(&n)
	s := make([]task, n)

	for i:=0; i<n; i++ {
		fmt.Scan(&t1, &t2)
		s[i] = task{time: t1, end: t2}
	}

	sort.Sort(tasks(s))
	total := 0

	for i:=0; i<n; i++ {
		total += s[i].time
		if total > s[i].end {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>

int main()
{
    uint64_t x, y, z, k;
    std::cin >> x >> y >> z >> k;
    uint64_t xx[1000], yy[1000], zz[1000], foo[1000000];
    for (int i = 0; (i < x); ++i) {
        std::cin >> xx[i];
    }
    for (int i = 0; (i < y); ++i) {
        std::cin >> yy[i];
    }
    for (int i = 0; (i < z); ++i) {
        std::cin >> zz[i];
    }
    std::sort(xx, xx + x);
    std::sort(yy, yy + y);
    std::sort(zz, zz + z);
    int xi = x - 1, yi = y -1, zi = z - 1;
    uint64_t max = xx[xi];
    max = std::max(max, yy[yi]);
    max = std::max(max, zz[zi]);
    int index = 0;
    int lane[1000];
    if (max == xx[xi]) {
        for (int i = 0; (i < y); ++i) {
            for (int j = 0; (j < z); ++j) {
                foo[index++] = yy[i] + zz[j];
            }
        }
        std::sort(foo, foo + (y * z));
        for (int i = 0; (i < x); ++i) {
            lane[i] = y * z - 1;
        }
        for (int i = 0; (i < k); ++i) {
            uint64_t max = 0;
            int maxIdx = 0;
            for (int j = x - 1; (j >= 0); --j) {
                if (lane[j] >= 0 && max < xx[j] + foo[lane[j]]) {
                    max = xx[j] + foo[lane[j]];
                    maxIdx = j;
                }
            }
            std::cout << max << std::endl;
            lane[maxIdx]--;
        }
    } else if (max == yy[yi]) {
        for (int i = 0; (i < x); ++i) {
            for (int j = 0; (j < z); ++j) {
                foo[index++] = xx[i] + zz[j];
            }
        }
        std::sort(foo, foo + (x * z));
        for (int i = 0; (i < y); ++i) {
            lane[i] = x * z - 1;
        }
        for (int i = 0; (i < k); ++i) {
            uint64_t max = 0;
            int maxIdx = 0;
            for (int j = y - 1; (j >= 0); --j) {
                if (lane[j] >= 0 && max < yy[j] + foo[lane[j]]) {
                    max = yy[j] + foo[lane[j]];
                    maxIdx = j;
                }
            }
            std::cout << max << std::endl;
            lane[maxIdx]--;
        }
    } else {
        for (int i = 0; (i < x); ++i) {
            for (int j = 0; (j < y); ++j) {
                foo[index++] = xx[i] + yy[j];
            }
        }
        std::sort(foo, foo + (x * y));
        for (int i = 0; (i < z); ++i) {
            lane[i] = x * y - 1;
        }
        for (int i = 0; (i < k); ++i) {
            uint64_t max = 0;
            int maxIdx = 0;
            for (int j = z - 1; (j >= 0); --j) {
                if (lane[j] >= 0 && max < zz[j] + foo[lane[j]]) {
                    max = zz[j] + foo[lane[j]];
                    maxIdx = j;
                }
            }
            std::cout << max << std::endl;
            lane[maxIdx]--;
        }
    }

    return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(i64, a, b, c, K);
    if (a >= K) {
        print(K);
    } else {
        print(a + max<i64>(0, K - (a + b)) * -1);
    }

    return 0;
}


Measured memory_bytes: 3648
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n = read();
    let s: Vec<String> = readn(n);

    let mut cnt = vec![255; 26];
    for s in s {
        let mut part = vec![0; 26];
        for x in s.into_bytes() {
            part[(x - 'a' as u8) as usize] += 1;
        }
        for i in 0..26 {
            cnt[i] = min(cnt[i], part[i]);
        }
    }

    for i in 0..26 {
        for _ in 0..cnt[i] {
            print!("{}", ('a' as u8 + i as u8) as char);
        }
    }
    println!();
}

Measured memory_bytes: 4352