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

// Union-Find, 0-indexed
struct UnionFind {
    int size; // 木の数
    UnionFind(int N) : par(N), scale1(N,1), size(N){
        iota(par.begin(), par.end(), 0);
    }

    int root(int x){
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    // xの木とyの木を併合
    void unite(int x, int y){
        int rx = root(x), ry = root(y);
        if (rx == ry) return;
        par[ry] = rx;
        scale1[rx] += scale1[ry];
        size--;
    }

    // 2つのデータx, yが属する木が同じならtrueを返す関数
    bool same(int x, int y){ return root(x) == root(y);}
    // xの属する木の要素の数を返す関数
    int scale(int x){ return scale1[root(x)];}

private:
    vector<int> par, scale1;
};


int main() {
    int N,M;
    cin >> N >> M;
    vector<int>A(M);
    vector<int>B(M);
    for (int i = 0; i < M; ++i) {
      cin >> A[i] >> B[i];
    }

    UnionFind tree(N);
    vector<ll>ans(M);
    ll temp = N;
    temp = (temp * (temp-1)) / 2;
    for(int i = M - 1; i >= 0; --i){
        ans[i] = temp;
        if(! tree.same(A[i]-1, B[i]-1)){
            ll aS = tree.scale(A[i]-1);
            ll bS = tree.scale(B[i]-1);
            temp = temp - aS * bS;
            tree.unite(A[i]-1, B[i]-1);
        }
    }

    for (int i = 0; i < M; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++)cin >> A[i];
    for(int i=0;i<n;i++){
        int v = A[i];
        int j = i-1;
        while(j>=0&&A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int j = 0;j<n;j++){
            cout << A[j];
            if(j!=n-1)cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 18;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9) return 10;
  if (x >= (long long)1e8) return 9;
  if (x >= (long long)1e7) return 8;
  if (x >= (long long)1e6) return 7;
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  if (pt_out > buf_size - 32) flush();
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int mn1 = INF, mx1 = -INF, mn2 = INF, mx2 = -INF;
  REP(i, N) {
    int x, y;
    scan(x);
    scan(y);
    int a = x + y, b = x - y;
    mn1 = min(mn1, a);
    mx1 = max(mx1, a);
    mn2 = min(mn2, b);
    mx2 = max(mx2, b);
  }
  println(max(mx1 - mn1, mx2 - mn2));
  return 0;
}

Measured memory_bytes: 3868
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()

    val robots = Array(n) { Robot(sc.nextInt(), sc.nextInt()) }.sortedBy { it.x - it.l }

    println(solve(robots, 0))
}

val solved = Array((1e5 + 1).toInt()) { -1 }
fun solve(robots: List<Robot>, x: Int): Int {
    if (solved[x] != -1) return solved[x]
    if (x == robots.size) return 0

    val notPick = solve(robots, x + 1)
    val R = robots[x].x + robots[x].l

    var a = x
    var b = robots.size
    while (b - a > 1) {
        val c = (b + a) / 2
        if (robots[c].x - robots[c].l >= R) b = c
        else a = c
    }

    val pick = 1 + solve(robots, b)

    val ans = if (pick > notPick) pick else notPick
    solved[x] = ans
    return ans
}

data class Robot(val x: Int, val l: Int)

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 82396
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

int main(){

  ll n,k;
  cin >> n >> k;

  for(int i=1;i<=k;i++){
    ll a;
    a=combmod(n-k+1,i,mod);
    a=(a*combmod(k-1,i-1,mod))%mod;
    cout << a << endl;
  }
  


}

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

int main()
{
   int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
   int prime=0, sec=0;
   int dp[n][3];
   for(int i=0;i<n;i++){
       
       for(int j=0;j<3;j++){
           if(i==0){
               dp[i][j]= a[i][j];
           }
           else{
               if(dp[i-1][j]==prime){
                   dp[i][j]= a[i][j]+sec;
               }
               else{
                   dp[i][j]= a[i][j]+prime;
               }
           }
       }
       
       for(int j=0;j<3;j++){
           if(prime< dp[i][j]){
            sec=prime;   prime=dp[i][j]; 
           }
           else if(dp[i][j] > sec){
               sec = dp[i][j];
           }
       }
       
   }
   
   int ans = INT_MIN;
   for(int i=0;i<3;i++){
       ans= max(ans,dp[n-1][i]);
   }
   cout<<ans; 

    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
	int y[2],m[2],d[2],n[]={0,31,28,31,30,31,30,31,31,30,31,30,31},ans,i;
	while(scanf("%d%d%d%d%d%d",&y[0],&m[0],&d[0],&y[1],&m[1],&d[1])!=EOF){
		if(y[0]<0 || y[1]<0 || m[0]<0 || m[1]<0 || d[0]<0 || d[1]<0)break;
		ans=0;
		if(y[0]==y[1]){
			if(m[0]==m[1]){
				ans=d[1]-d[0];
			}else{
				ans=n[m[0]]-d[0]+1+d[1]-1;
				for(i=m[0]+1;i<m[1];i++)ans+=n[i];
			}
		}else{
			ans+=n[m[0]]-d[0]+1;
			for(i=m[0]+1;i<=12;i++)ans+=n[i];
			ans+=d[1]-1;
			for(i=1;i<m[1];i++)ans+=n[i];
			
			if(y[1]-y[0]>1)ans+=((y[1]-1)-(y[0]))*365;
			for(i=y[0]+1;i<y[1];i++)if((i%4==0 && i%100!=0) || i%400==0)ans++;
			
			if(m[0]==1 || (m[0]==2 && d[0]==29))
				if((y[0]%4==0 && y[0]%100!=0) || y[0]%400==0)ans++;
			if(m[1]>2 || (m[1]==2 && d[1]==29))
				if((y[1]%4==0 && y[1]%100!=0) || y[1]%400==0)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

// １～１００までの場所の値を
// １～１００人について計算する
// worst O(10000) かな？

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

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

	int min = 200000000;

	vector<int> answers(100); // １～１００の場所について
	for (int i = 0; i < 100; i++) // １～１００の場所について
	{
		for (int j = 0; j < N; j++) // 各人の疲れポイント集計（ N人 ）
		{
			answers.at(i) += ((i + 1) - X.at(j)) * ((i + 1) - X.at(j));
		}
		if (min > answers.at(i)) 
		{
			min = answers.at(i);
		}
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
f=lambda:map(int,input().split())
N,X=f()
*A,=f()
A=[0]+A

c=0
for i in range(N):
 c+=max(0,A[i]+A[i+1]-X)
 A[i+1]=min(A[i+1],X-A[i])
print(c)

Measured memory_bytes: 20080
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    
    vector<int> box(n,1);
    vector<bool> red(n,false);
    red[0]=true;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        box[x]--;
        box[y]++;
        if(red[x]) red[y]=true;
        if(box[x]==0) red[x]=false;
    }
    
    int ans=0;
    rep(i,0,n){
        if(red[i]) ans++;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 640
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{	
	
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		String s = scan.next();
		char[] a = s.toCharArray();
		if(a[k-1]>='A'&&a[k-1]<='Z'){
			a[k-1] = (char)(a[k-1]-'A'+'a');
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  modint pow(u64 exp){
    modint res=1,rhs=*this;
    while (exp) {
      if (exp % 2) {
        res *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return res;
  }

  friend ostream& operator<<(ostream& os,modint& rhs){
    os << rhs.value();
    return os;
  }

  friend istream& operator>>(istream &is,modint &rhs){
      is>>rhs.value();
      rhs.value()%=Modulus;
      return is;
  }

};
using mint=modint<(ll)1e9+7>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  vector<mint>dp(k+1);
  dp[0]=1;
  rep(i,n){
    ll a;cin>>a;a++;
    auto tdp=dp;
    rep(j,k+1){
      if(j+a<k+1)dp[j+a]-=tdp[j];
      else break;
    }
  }
  rep(i,n){
    rep(j,k){
      dp[j+1]+=dp[j];
    }
  }
  cout<<dp[k]<<endl;

  return 0;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll gcd(ll a, ll b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  return (a * b) / gcd(a, b);
}

// int main(int argc, char** argv) {
//   int n, m;
//   cin >> n >> m;
//
//   cout << gcd(n, m) << endl;
// }

// The number of 2 in x.
int f(int x) {
  int res = 0;
  while (x%2 == 0) {
    x /= 2;
    ++res;
  }
  return res;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    a[i] /= 2;
  }

  int t = f(a[0]);
  rep(i, n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // a[i] /= 2^t
  }
  m >>= t;

  ll l = 1;
  rep(i, n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  ll ans = (m+1)/2; // the count of odd numbers in [1, m].
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const int mod = 1e9 + 7;
int Mod(int x){x%=mod;if(x<0)x+=mod;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()

vi fact;

int comb(int n, int r) {
	if(r==n or r==0) return 1;
	int num=fact[n];
	int den=Mod(fact[r]*fact[n-r]);
	den = Pow(den,mod-2);
	return Mod(num*den);
}

int calc(int n,int r) {
	return comb(n+r-1,r-1);
}

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

	int ans = 0;
	fact = vi(2*n+1,1);
	
	for(int i=1;i<=2*n;i++) {
		fact[i]=Mod(fact[i-1]*i);
	}

	for(int i=0;i<=min(k,n-1);i++) {
		int rs = comb(n,i);
		int div = calc(i,n-i);
		ans = Mod(ans + rs * div);
	}

	cout << ans << endl;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] candies = new int[3];
        for (int i = 0; i < 3; i++) {
            candies[i] = sc.nextInt();
        }
        Arrays.sort(candies);

        if (candies[0] + candies[1] == candies[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N, K, S; cin >> N >> K >> S;
	int i = 0;

	for (i = 0; i < K; i++) {
		cout << S << " ";
	}
	if (S < 100) {
		for (; i < N; i++) {
			cout << 100 << " ";
		}
	}
	else {
		for (; i < N; i++) {
			cout << S - 1 << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    ll check = -1;
    ll use;
    for(ll i = 0; i < n-1; i++){
        check = max(check, min(a[n-1]-a[i], a[i]));
    //    cout << check << endl;
        if(check == min(a[n-1]-a[i], a[i]))
            use = a[i];
    }
    cout << a[n-1] << " " << use << endl;
        
    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
static const llint INF = 1e18;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string s, t;
    cin >> s >> t;

    unordered_map<char, vector<int>> mp;
    llint ns = s.size(), nt = t.size();
    for(llint is=0;is<ns;++is) {
        char cs = s[is];
        mp[cs].push_back(is);
    }
    for(llint it=0;it<nt;++it) {
        char ct = t[it];
        if(mp.count(ct)==0) {
            cout << -1 << endl;
            return 0;
        }
    }

    llint ans = 0;
    int now = 0;
    for(llint it=0;it<t.size();++it) {
        char c = t[it];
        auto itr = lower_bound(mp[c].begin(), mp[c].end(), now);
        if(itr==mp[c].end()) {
            ans += ns - now;
            now = mp[c][0] + 1;
            ans += now;
        }
        else {
            ans += *itr - now + 1;
            now = *itr + 1;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long li;
const li MAX = 3000;
li n, a, b, w, inf = 99999999999;
long double dp[MAX][MAX], coins[MAX];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> coins[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] * (1 - coins[i]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j - 1] * coins[i] + dp[i - 1][j] * (1 - coins[i]);
 		}
	}
	long double ans = 0;
	for (li i = n / 2 + 1; i <= n; i++) {
		ans += dp[n][i];
	}
	cout << fixed;
	cout.precision(12);
	cout << ans;
//	system("pause");
	return 0;
}

Measured memory_bytes: 139136
program sample
	implicit none
    integer(8) :: N,i,j
    integer,allocatable :: x(:),y(:),a(:),b(:),c(:)
    
    read(*,*) N
    
    allocate(x(N))
    allocate(y(N))
    allocate(a(N))
    allocate(b(N))
    allocate(c(N))
    
    read(*,*) x
    read(*,*) y
    
    !aは前から配列の中身を対していったものの和
    do i = 1,N
    	if ( i==1 ) then
        	a(i) = x(i)
        else
    		a(i) = a(i-1) +x(i)
    	end if
    end do
    
    !bは後ろから配列の値を足していったものの和
    do i=1,N
    	if ( i==1) then
        	b(i) = y(N-i+1)
        else
        	b(i) = b(i-1) + y(N-i+1)
    	end if
    end do

    
    do i=1,N
    	c(i) = a(i)+b(N-i+1)
    end do
    
    write(*,*) maxval(c)
    
    deallocate(x)
    deallocate(y)
    deallocate(a)
    deallocate(b)
    deallocate(c)
    
    stop
end program sample

Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)

const MAX = 1000000000000000000

var A, B string

func main() {
	sc.Split(bufio.ScanWords)
	A, B = nextStr(), nextStr()

	if A == "0" || B == "0.00" {
		fmt.Println(0)
		return
	}

	var ans, b, c int64
	a, _ := strconv.ParseInt(A, 10, 64)
	ans = 0
	b = 100
	var r float64
	r = 0.0
	for i := len(B) - 1; i >= 0; i-- {
		if string(B[i]) == "." {
			continue
		}
		c, _ = strconv.ParseInt(string(B[i]), 10, 64)
		if c != 0 {
			diff := int64(a * c / b)
			r += float64(a*c%b) / float64(b)
			ans += diff
		}
		b /= 10
	}

	fmt.Println(ans + int64(r))

}


Measured memory_bytes: 1760
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string l;
long long mod = 1000000007,ans = 0;
ll pw(ll x, ll a){
	ll ret = 1;
	while(a){
		while(!(a&1)){
			(x *= x) %= mod;
			a /= 2;
		}
		(ret *= x) %= mod;
		a--;
	}
	return ret;
}
int main(){
	cin >> l;
	int i,n = l.size();
	ll sum = 1;
	for(i=0;i<n;i++){
		if(l[i]=='1'){
			(ans += sum*pw(3,n - 1 - i)%mod) %= mod;
			(sum *= 2) %= mod;
		}
	}
	(ans += sum) %= mod;
	cout << ans << endl;
}
			
		
		

Measured memory_bytes: 512
function main(input) {
  var marginDelete = input.trim();
  var args = marginDelete.split(' ');
  var n = parseInt(args[0], 10);
  var r = parseInt(args[1], 10);
  var hiddenRating;
  if ( n >= 10) {
    hiddenRating = r;
  } else {
    var argument = 100*(10 - n);
    hiddenRating = r + argument;
  }
  return hiddenRating;
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

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

const int lim = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    //最後に選び方を求めるときに使う配列
    vector<int> p;

    //題意を満たすような並び方が存在するかのチェックを行う。
    vector<int> num(N);
    //Nが偶数の場合
    if(N % 2 == 0){
        //差の値の種類と、それぞれの数を数える
        rep(i, N) num[a[i]]++;
        //正しさチェック
        bool is = true;
        rep(i, N){
            //差の個数が偶数個の者は存在しない
            if(i % 2 == 0 && num[i] != 0) is = false; 
            //差の個数が奇数個の者は必ず2つ存在
            if(i % 2 == 1 && num[i] != 2) is = false;
        }
        if(!is){
            cout << 0 << endl;
            return 0;
        }
    }else{ //Nが奇数の場合
        rep(i, N) num[a[i]]++;
        bool is = true;
        rep(i, N){
            if(i == 0 && num[i] != 1) is = false;
            if(i != 0 && i % 2 == 0 && num[i] != 2) is = false;
            if(i % 2 == 1 && num[i] != 0) is = false;
        }
        if(!is){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N) if(num[i] != 0) p.push_back(num[i]);
    ll ans = 1;
    for(int v : p) ans = (ans * v) % lim;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4308
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a, b, h, m;
    long double x, c, c_sq;
    const double pi = acos(-1.0);
    
    cin >> a >> b >> h >> m;
    
    x = (2.0 * pi) * (((long double) (h + (m / 60.0)) / 12.0) - (long double) (m / 60.0));
    if (x > pi)
    {
        x = (2 * pi) - x;
    }
    
    c_sq = (long double) ((a * a) + (b * b)) - (long double) ((2.0 * a * b) * cos(x));
    c = sqrt(c_sq);
    
    cout << fixed << setprecision(20) << c;
    
    return 0;
}

Measured memory_bytes: 4184
#include<stdio.h>
#include <limits.h>  
#define inf (INT_MAX-1)
int Max(int a, int b) { if (a>b) { return a; }return b; }
int Min(int a, int b) { if (a<b) { return a; }return b; }
int main() {
	int A, B, C, X, Y;
	int tmp,ans=inf;
	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

	for (int i = 0; i <= 100000; i++)
	{
		tmp = i * 2 * C + Max(0, X - i)*A + Max(0, Y - i)*B;
		ans = Min(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)

int a, b;
int main() {
	scanf("%d %d", &a, &b);
	if (a <= 0 && b >= 0) puts("Zero");
	else if (b < 0 && (b-a+1)%2) puts("Negative");
	else puts("Positive");



	return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main(void) {
  string number;
  int answer = 0;
  while(cin >> number && number[0] != '0') {
    for(int i = 0; i < number.length(); i++) {
      answer += number[i] - '0';
    }
    cout << answer << endl;
    answer = 0;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <malloc.h>
using namespace std;
int n;
struct node
{
    int val;
    node *left,*right;
};
node * root;
void init()
{
    root=NULL;
}
void Insert (int temp)
{
    node *x=root,*y=NULL;
    node *now=(node *)malloc(sizeof(node));
    now->left=now->right=NULL;
    now->val=temp;
    while (x)
    {
        y=x;
        x=x->val>temp? x->left:x->right;
    }
    y==NULL? root=now:y->val>temp?y->left=now:y->right=now;
}
bool Find (int x)
{
    node * p=root;
    while (p)
    {
        if(p->val==x)
            return true;
        else if(p->val<x)
            p=p->right;
        else
            p=p->left;
    }
    return false;
}
void pretraverse (node * nd)
{
    if(nd==NULL)
        return ;
    printf(" %d",nd->val);
    pretraverse (nd->left);
    pretraverse (nd->right);
}
void intraverse (node * nd)
{
    if(nd==NULL)
        return ;
    intraverse (nd->left);
    printf(" %d",nd->val);
    intraverse (nd->right);
}
void output ()
{
   intraverse (root);
   printf("\n");
   pretraverse (root);
   printf("\n");

}
int main()
{
    scanf("%d",&n);
    init();
    while (n--)
    {
        char s[10];
        scanf("%s",s);
        if(s[0]=='i')
        {
            int x;
            scanf("%d",&x);
            Insert (x);
        }
        else if(s[0]=='f')
        {
            int x;
            scanf("%d",&x);
            if(Find(x))
                printf("yes\n");
            else
                printf("no\n");
        }
        else
            output();
    }
    return 0;
}



Measured memory_bytes: 15672
#C
import math
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):  #n面ダイスがiを示したとき
    if i<k:
        m = math.ceil(math.log2(k / i))
        # print(i,m)
        ans += 1 / (2**m) / n
        # print(ans)
    else:
        ans += 1 / n
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
    int tuki,hi,youbi=4;
    while(1){
        scanf("%d %d",&tuki,&hi);
        if(tuki==0) break;
        switch(tuki){
            case 2: youbi=youbi+31+hi-1;
                break;
            case 3: youbi=youbi+60+hi-1;
                break;
            case 4: youbi=youbi+91+hi-1;
                break;
            case 5: youbi=youbi+121+hi-1;
                break;
            case 6: youbi=youbi+152+hi-1;
                break;
            case 7: youbi=youbi+182+hi-1;
                break;
            case 8: youbi=youbi+213+hi-1;
                break;
            case 9: youbi=youbi+244+hi-1;
                break;
            case 10: youbi=youbi+274+hi-1;
                break;
            case 11: youbi=youbi+305+hi-1;
                break;
            case 12: youbi=youbi+335+hi-1;
                break;
        }
        youbi=youbi%7;
        switch(youbi){
            case 0:puts("Sunday");
                break;
            case 1:puts("Monday");
                break;
            case 2:puts("Tuesday");
                break;
            case 3:puts("Wednesday");
                break;
            case 4:puts("Thursday");
                break;
            case 5:puts("Friday");
                break;
            case 6:puts("Saturday");
                break;
        }
        youbi=4;
    }
    return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
#define ll              long long int
#define ull             unsigned long long int
#define mod             1000000007 
#define pb              push_back
#define mp              make_pair
#define count_1(n)      __builtin_popcountll(n) //set bits


bool isPrime(ll n) {

  if (n == 1) {
    return false;
  }

  for (ll i = 2; i*i <=n; i++) {
    if (n % i == 0) return false;
  }

  return true;
}

 
   
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     
    x = x % p;  
                
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    return -1; 
} 

  

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    
    int sum=0;
    for(int i=0;i<s.size();i++){
        sum+=(s[i]-'0');
    }
    if(sum%9)
        cout<<"No";
    else
        cout<<"Yes";
}

Measured memory_bytes: 3700
package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scanln(&n)

	var official_house [4][3][10]int

	for i := 0; i < n; i++ {
		scanner.Scan()
		string := scanner.Text()
		words := strings.Split(string, " ")

		b, _ := strconv.Atoi(words[0])
		f, _ := strconv.Atoi(words[1])
		r, _ := strconv.Atoi(words[2])
		v, _ := strconv.Atoi(words[3])

		official_house[b-1][f-1][r-1] += v
	}


	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", official_house[i][j][k])
			}
			fmt.Printf("\n")
		}
		if i < 3 {
			fmt.Printf("####################\n")
		}
	}
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d){
    cout << "Yes" << endl;
  }
  else if(abs(a-b)<=d && abs(b-c)<=d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<char(toupper(s1[0]))<<char(toupper(s2[0]))<<char(toupper(s3[0]))<<endl;
    return 0;
}

Measured memory_bytes: 3616
#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;
   int abc[3];
   bool flag = false;
   if(7==N/100) flag = true;
   N = N - (N/100)*100;
   if(7==N/10) flag = true;
   N = N - (N/10)*10;
   if(7==N) flag = true;
   if(flag) cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;  
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    set<string>se;
    string s,t,w1,w2;
    string m[n][2];
    r(i,n)cin>>m[i][0]>>m[i][1];
    cin>>s>>t;
    queue<pair<string,int> >q;
    q.push(mk(s,0));
    se.insert(s);
    while(!q.empty()){
      pair<string,int>p=q.front();q.pop();
      string tt=p.first;
      if(tt==t){cout<<p.second<<endl;goto L;}
      for(int i=0;i<n;i++){
        string g,x;
        for(int j=0;j<tt.size();j++){
          string y;
          int hh=0;
          for(int k=j;k<tt.size()+1;k++){
            if(y==m[i][0]){hh++;j=k-1;break;}
            if(k>=tt.size())break;
            y+=tt[k];
          }
          if(!hh)g+=tt[j];
          else g+=m[i][1];
        }
        if(!se.count(g)&&g.size()<=t.size()){
          q.push(mk(g,p.second+1));
          se.insert(g);
        }
      }
    }
    cout<<-1<<endl;L:;
  }
}

Measured memory_bytes: 3208
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    int cnt[5] = {};
    string s;
    cin >> n;
    REP(i,0,n) {
        cin >> s;
        if (s[0] == 'M') cnt[0]++;
        if (s[0] == 'A') cnt[1]++;
        if (s[0] == 'R') cnt[2]++;
        if (s[0] == 'C') cnt[3]++;
        if (s[0] == 'H') cnt[4]++;
    }
    LL ans = 0;
    REP(i,0,3) REP(j,i+1,4) REP(k,j+1,5) ans += (LL)cnt[i] * cnt[j] * cnt[k];
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
constexpr double inf = 1e18;
struct nagata {
  vector<double> miv, mav;
  nagata() {
    miv.assign(3,  inf);
    mav.assign(3, -inf);
  }
  void insert (int x, int i) {
    i++;
    cmn(miv[i], x);
    cmx(mav[i], x);
  }
  double breadth (double t) const {
    return max(0., 
      max({
        mav[0],
        mav[1] + t,
        mav[2] + t * 2
      }) -
      min({
        miv[0],
        miv[1] + t,
        miv[2] + t * 2
      })
    );
  }
  auto singular () const {
    vector<double> ret;
    for (int i = 0; i < 3; i++) {
      for (int j = i + 1; j < 3; j++) {
        auto change = [&] (auto v) {
          if (v[i] == inf || v[i] == -inf) return;
          if (v[j] == inf || v[j] == -inf) return;
          if (v[j] < v[i]) ret.push_back((v[i] - v[j]) / (j - i));
        };
        change(miv), change(mav);
      }
    }
    return ret;
  }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  nagata hor, ver;
  for (int i = 0; i < n; i++) {
    int x, y; char d;
    cin >> x >> y >> d;
    hor.insert(x,
      d == 'R' ? 1 : (d == 'L' ? -1 : 0)
    );
    ver.insert(y,
      d == 'U' ? 1 : (d == 'D' ? -1 : 0)
    );
  }
  double ret = 1e18;
  vector<double> sgl = {0.};
  auto ins = [&] (const nagata& ngt) {
    auto s = ngt.singular();
    sgl.insert(sgl.end(), s.begin(), s.end());
  };
  ins(hor), ins(ver);
  for_each(sgl.begin(), sgl.end(), [&](auto t){cmn(ret,
      hor.breadth(t) *
      ver.breadth(t)
    );});
  cout << setprecision(10) << ret << endl;
  return 0;
}

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

int main() {
  int n,m; std::cin >> n >> m;
  priority_queue<int> A;
  for (size_t i = 0; i < n; i++) {
    int a; std::cin >> a;
    A.push(a);
  }
  for (size_t i = 0; i < m; i++) {
    int tmp = A.top()/2;
    A.pop();
    A.push(tmp);
  }
  int64_t ans = 0;
  for (size_t i = 0; i < n; i++) {
    ans += A.top();
    A.pop();
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int a, sum;
int main() {
	rep(i,3) {cin >> a; sum += a;}
	if (sum < 22) cout << "win" << endl;
	else cout << "bust" << endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


signed main(){
	int N;
	cin>>N;
	vint D(N);rep(i,N)cin>>D[i];

	int ans=0;
	rep(i,N)for(int j=i+1;j<N;j++)ans+=D[i]*D[j];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  string s;
  cin>>s;
  vector<char> v;
  for(int i=0; i<s.length(); i++)
  {
    if(s[i] == 'B')
    {
      if(!v.empty())
      v.pop_back();
    }
    else
    {
      v.push_back(s[i]);
    }
  }
  for(char x: v)
    cout<<x;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int sum=1;
		cin >> s;
		for(int i=1;i<n;i++){
				if(s[i]!=s[i-1])
					sum++;
		}
		printf("%d\n",sum);	
	}
}

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

using i64 = long long int;

int main(){
    i64 n, p, q;
    cin >> n >> p >> q;

    vector<i64> v;
    i64 sum = 0;
    for(i64 i=1;i<=n;++i){
        i64 c;
        cin >> c;
        v.push_back(p*i + c);
        sum += c;
    }

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

    i64 ans = sum, acc = 0;
    for(i64 i=0;i<n;++i){
        acc += v[i];
        i64 m = i + 1;
        i64 tmp = sum + m*p*(m+q) - acc;
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

	double t, x;
	cin >> t >> x;
	cout << t / x << endl;



	return 0;
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
K = lines[0][1]
Mod = 10 ** 9 + 7

access = []
for i in 1..N do
  access[i-1] = []
end
for i in 1..N-1 do
  from = lines[i][0]
  to = lines[i][1]
  access[from-1].push(to)
  access[to-1].push(from)
end

adj_col = []
visited = []
for i in 1..N do
  adj_col[i-1] = 0
  visited[i-1] = false
end

ans = 1
target = [1]
impossible = false
while target != [] do
  i = target.pop
  visited[i-1] = true
  adj2_col = 0
  access[i-1].each do |j|
    adj2_col += adj_col[j-1]
    adj_col[j-1] += 1
    if visited[j-1] == false then
      target.push(j)
    end
  end
  if adj_col[i-1] + adj2_col >= K then
    impossible = true
    break
  else
    ans = (ans * (K - adj_col[i-1] - adj2_col)) % Mod
  end
end
    
if impossible then
  puts 0
else
  puts ans
end

Measured memory_bytes: 18564
import sys
import numpy as np
from numba import njit

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


@njit('i8[:](i8,i8,i8[:])', cache=True)
def func(n, k, A):
    for _ in range(k):
        B = np.zeros(n + 1, np.int64)
        for i, a in enumerate(A):
            B[max(0, i - a)] += 1
            B[min(i + a + 1, n)] -= 1
        A = B.cumsum()[:-1]
        if np.all(A == n):
            break
    return A


def main():
    N, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)
    ans = func(N, K, A)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 119816
import java.util.*;
import java.io.*;
class Main{
    public static int count=0;
    public static int[] l;
    public static int[] r;
    public static void main(String args[]){
	l = new int[500000];
	r = new int[500000];
	int i,n;
	int s[] = new int[500000];
	Scanner scan = new Scanner(System.in);
	
	n = scan.nextInt();
	for(i=0;i<n;i++){
	    s[i] = scan.nextInt();
	}
	mergeSort(s,0,n);
	for(i=0;i<n;i++){
	    if(i==n-1){
		System.out.println(s[i]);
		System.out.println(count);
		continue;
	    }
	    System.out.print(s[i]+" ");
	}
    }

    public static void merge(int s[],int left,int mid,int right){
	int i,j,k,n1,n2;
	n1 = mid -left;
	n2 = right - mid;
	
	for(i=0;i<n1;i++){
	    l[i] = s[left+i];
	}
	for(i=0;i<n2;i++){
	    r[i] = s[mid+i];
	}
	l[n1] = 2147483647;
	r[n2] = 2147483647;
	i=0;
	j=0;
	for(k=left;k<right;k++){
	    if(l[i]<=r[j]){
		s[k] = l[i];
		i = i+1;
		count++;
	    }
	    else{
		s[k] = r[j];
		j = j+1;
		count++;
	    }
	}
    }
    
    public static void mergeSort(int s[],int left,int right){
	int mid=0;
	// int a[] = new int[100000];
	if(left+1<right){ /*分割する*/
	    mid = (left+right)/2;
	    mergeSort(s,left,mid);
	    mergeSort(s,mid,right);
	    merge(s,left,mid,right);
	}
    }
    
}



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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> L(M), R(M);
	for (int i = 0; i < M; i++)
	{
		cin >> L[i] >> R[i];
	}

	int l = 1, r = N;
	for (int i = 0; i < M; i++)
	{
		l = max(l, L[i]);
		r = min(r, R[i]);
	}

	int ans = max(0, r - l + 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024