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

cnt = 0
ans = [0]*l
#R判定
for i, j in enumerate(s):
  if j == "R":
    cnt += 1
  else:
    N_even = cnt//2
    N_odd = cnt - N_even
    ans[i] += N_even
    ans[i-1] += N_odd
    cnt = 0

#L判定
cnt = 0
for p in range(l-1, -1, -1):
  if s[p] == "L":
    cnt += 1
  else:
    n_even = cnt//2
    n_odd = cnt - n_even
    ans[p] += n_even
    ans[p+1] += n_odd
    cnt = 0
print(*ans)

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
 
int frog(int arr[], int dp[], int n){
  if(dp[n-1] != -1)
        return dp[n-1];
  else
        {
          dp[n-1] = min(frog(arr, dp, n-1)+ abs(arr[n-1] - arr[n-2]), frog(arr, dp, n-2) + abs(arr[n-1] - arr[n-3]));
          return dp[n-1];
        }
}
int main() {
  int n;
  cin>>n;
  int arr[n];
  int dp[n];
  for(int i = 0 ; i < n ; i++){cin>>arr[i]; dp[i] = -1;}
  
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  
  cout<<frog(arr, dp, n);
  
  
  return 0;
}

Measured memory_bytes: 8216
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string S,T;
    ll A[MAX_N];
    ll answer = 0;
    bool good;
    //cin >> a >> b >> c >> d;
    cin >> S >> T;
    //rep(i, N) cin >> A[i];
    ll n = S.length();
    rep(i, n){
        good = true;
        rep(j, n){
            ll idx = (i+j) % n;
            if (S[idx] != T[j]) {good = false; break;}
        }
        if (good) break;
    }
    if (good) cout  << "Yes"<< endl;
    else cout << "No" << endl; 
    //cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
q = gets.to_i
q.times{
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_i)
  if x0 < x1 && ((x2 < x0 && x3 < x0) || (x1 < x2 && x1 < x3))
    puts 0
  elsif x1 <= x0 && ((x2 < x1 && x3 < x1) || (x0 < x2 && x0 < x3))
    puts 0
  elsif y0 < y1 && ((y2 < y0 && y3 < y0) || (y1 < y2 && y1 < y3))
    puts 0
  elsif y1 <= y0 && ((y2 < y1 && y3 < y1) || (y0 < y2 && y0 < y3))
    puts 0
  else
    t0 = (x0-x1) * (y2-y0) + (y0-y1) * (x0-x2)
    t1 = (x0-x1) * (y3-y0) + (y0-y1) * (x0-x3)
    t2 = (x2-x3) * (y0-y2) + (y2-y3) * (x2-x0)
    t3 = (x2-x3) * (y1-y2) + (y2-y3) * (x2-x1)
    if t0 * t1 <= 0 && t2 * t3 <= 0
      puts 1
    else
      puts 0
    end
  end
}

Measured memory_bytes: 8840
# -*- coding: utf-8 -*-


def gcd(x, y):
    # GCD(Greatest Common Divisor)
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    print(x)


def to_xy(v):
    return [int(c) for c in v.split()]


if __name__ == '__main__':
    x, y = to_xy(input())
    gcd(x, y)

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

int main() {
    vector<string>koho = {"AKIHBR","AKIHBAR","AKIHABR","AKIHABAR",
                          "AKIHBRA","AKIHBARA","AKIHABRA","AKIHABARA",
                          "KIHBR","KIHBAR","KIHABR","KIHABAR",
                          "KIHBRA","KIHBARA","KIHABRA","KIHABARA"};
    string s;
    std::cin >> s;
    for (auto e : koho) {
        if(e==s){
            std::cout << "YES" << std::endl;
            return 0;
        }
    }
    std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
signed main()
{
   int l,r;
   cin >> l >> r;
   if((l-1)/2019 != r/2019)
  { cout << 0; return 0;}
  int ans = 2018;
  l %= 2019; r %= 2019;
   for(int i=l;i<=r;i++)
   for(int j=i+1;j<=r;j++)
   ans = min(ans,(i*j)%2019);
   cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<int> x;
    if(n%2==0)x.push_back(0);
    else{
        x.push_back(1);
        n--;
    }
    n/=(-2);
    while(n!=(ll)0){
        if(n%2==0)x.push_back(0);
        else{
            x.push_back(1);
            n--;
        }
        n/=(-2);
    }
    reverse(x.begin(),x.end());
    rep(i,x.size()) cout<<x[i];
    cout<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,a,b;
  bool s=false;
  cin>>N;
  vector<int> v(N);
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
    vec[i]=v[i];
  }
  sort(v.begin(),v.end(),greater<int>());
  a=v[0];
  for(int j=1;j<N;j++){
    if (a==v[j]){
      s = true;}
    else{b=v[j];
        break;}
  }
  if(s){
    for(int k=0;k<N;k++){
      cout<<a<<endl;}
       }else{
  for(int k=0;k<N;k++){
  if(vec[k]==a){
    cout<<b<<endl;
  }else{
    cout<<a<<endl;}
  }
}
}

Measured memory_bytes: 3200
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, M, DP[100005];
vector <int> Graph[100005];

int Calc(int node){
  if (DP[node] != -1) return DP[node];
  int ans = 0;
  for (int i = 0; i < Graph[node].size(); i++){
    ans = max(ans, Calc(Graph[node][i]) + 1);
  }
  return DP[node] = ans;
}

int main(){
  scanf("%d%d", &N, &M);
  fill(DP, DP + N, -1);
  for (int i = 0; i < M; i++){
    int X, Y; scanf("%d%d", &X, &Y);
    X--; Y--;
    Graph[X].push_back(Y);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
    ans = max(ans, Calc(i));
  }
  printf("%d\n", ans);

  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<int>>a(h,vector<int>(w));
  vector<vector<int>>ans(h*w,vector<int>(4));
  rep(i,0,h) rep(j,0,w) cin >> a[i][j];
  int c = 0;
  rep(i,0,h){
    if(i%2 == 0){
      rep(j,0,w){
        if(a[i][j]%2 == 0) continue;
        if(j != w-1){
          ans[c][0] = i;
          ans[c][1] = j;
          ans[c][2] = i;
          ans[c][3] = j+1;
          a[i][j+1]++;
        }
        else{
          if(i == h-1) break;
          ans[c][0] = i;
          ans[c][1] = j;
          ans[c][2] = i+1;
          ans[c][3] = j;
          a[i+1][j]++;
        }
        c++;
      }
    }
    else{
      for(int j = w-1;j >= 0;j--){
        if(a[i][j]%2 == 0) continue;
        if(j != 0){
          ans[c][0] = i;
          ans[c][1] = j;
          ans[c][2] = i;
          ans[c][3] = j-1;
          a[i][j-1]++;
        }
        else{
          if(i == h-1) break;
          ans[c][0] = i;
          ans[c][1] = j;
          ans[c][2] = i+1;
          ans[c][3] = j;
          a[i+1][j]++;
        }
        c++;
      }
    }
  }
  cout << c << endl;
  rep(i,0,c) cout << ans[i][0]+1 << " " << ans[i][1]+1 << " " << ans[i][2]+1 << " " << ans[i][3]+1 << endl;
}

Measured memory_bytes: 17972
# frozen_string_literal: true

s = gets.to_i

# n, k = gets.split.map(&:to_i)


MOD = 10**9 + 7
N = s

def ncrmod(n, r)
  return 0 if r < 0 || r > n

  r = [r, n - r].min
  $g1[n] * $g2[r] * $g2[n - r] % MOD
end

$g1 = [1, 1]
$g2 = [1, 1]
$inverse = [0, 1]

2.upto(N + 1) do |i|
  $g1.push(($g1[-1] * i) % MOD)
  $inverse.push((-$inverse[MOD % i] * (MOD / i)) % MOD)
  $g2.push(($g2[-1] * $inverse[-1]) % MOD)
end

def nhr(n, r)
  ncrmod(n+r-1, r)
end

u = s / 3
c = s < 3 ? 0 : 1

2.upto(u) do |i|
  c += nhr(i, s - 3 * i)
  c %= MOD
end

puts c


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;


const ll inf = 1LL << 60;
void floydWarshall(vector<vector<ll>>& m) {
  int n = sz(m);
  rep(i,0,n) m[i][i] = min(m[i][i], 0LL);
  rep(k,0,n) rep(i,0,n) rep(j,0,n)
    if (m[i][k] != inf && m[k][j] != inf) {
      auto newDist = max(m[i][k] + m[k][j], -inf);
      m[i][j] = min(m[i][j], newDist);
    }
  rep(k,0,n) if (m[k][k] < 0) rep(i,0,n) rep(j,0,n)
    if (m[i][k] != inf && m[k][j] != inf) m[i][j] = -inf;
}


#ifdef LOCAL
#include "pretty_debug.h"
#else
#define debug(...) //ignore
#endif
int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
  int n;
  cin>>n;
  vector<vi> s(n, vi(n));
  rep(i,0,n) {
    string a;
    cin>>a;
    rep(j,0,n) s[i][j] = (a[j] == '1' ? 1 : inf);
  }

  floydWarshall(s);
  debug(s);
  rep(i,0,n) rep(j,0,n) rep(k,0,n) {
    if((s[i][j] + s[j][k] + s[k][i]) % 2) {
      cout << "-1" << endl;
      return 0;
    }
  }
  ll d = 0;
  rep(i,0,n) rep(j,0,n) d = max(d,s[i][j]);
  cout << d + 1 << endl;
}


Measured memory_bytes: 640
N = int(input())
S = str(input())
 
if N % 2 == 0:
  NN = int(N/2)
  for i in range(0, NN):
    if S[i] != S[i+NN]:
      print('No')
      break
  else:
    print('Yes')
    
else:
  print('No')

Measured memory_bytes: 9172
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9 + 7;

ll mpow(ll n, ll m) {
	if (n == 1)
		return m;

	ll ret = mpow(n / 2, m);
	ret = ret * ret % mod;
	if (n & 1)
		ret = ret * m%mod;

	return ret;
}

ll ncr(ll n, ll r) {
	ll ret = 1;
	for (int i = 1; i <= r; i++) {
		ret = ret * (n - i + 1) % mod;
		ret = ret * mpow(mod - 2, i) % mod;
	}
	return ret;
}


int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	ll ans = 0;

	for (int i = 1; i <= n - 1; i++) {
		ans = (ans + i * (n - i)*m*m) % mod;
	}
	for (int i = 1; i <= m - 1; i++) {
		ans = (ans + i * (m - i)*n*n) % mod;
	}

	cout << ans * ncr(n*m - 2, k - 2) % mod << endl;

}

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

int main(){
    int N;
    cin >> N;
    vector<int64_t> X(N), Y(N);
    for(int i=0; i<N; i++){
        int x, y;
        cin >> x >> y;
        X[i] = x+y;
        Y[i] = x-y;
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    auto ans = max(X[N-1] - X[0], Y[N-1] - Y[0]);
    cout << ans << endl;
    return 0;
}


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

int n,h[100005],c[100005];

int main()
{
    cin>>n;
    for (int i = 0;i<n;i++)
        cin>>h[i];
    c[1] = abs(h[0] - h[1]); c[2] = abs(h[0] - h[2]);
    for (int i = 3;i<=n;i++)
    {
        c[i] = min(c[i-1] + abs(h[i] - h[i-1]), c[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<c[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define reg register
typedef unsigned long long ll;
using namespace std;
int main(){
	reg double n,a=100;scanf("%lf",&n);
	reg int tot=0;
	while(a<n)a=floor(a*1.01),tot++;
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 3824
while line = gets do
  while line !~ /th(e|is|at)/
    line = line.unpack("C*").map{|n|
      if n >= 97 and n <= 122 then
        (n-97 + 1)%26+97
      else
        n
      end
    }.pack("C*")
  end
  puts line
end

Measured memory_bytes: 8636
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<tuple>

using namespace std;

typedef tuple<int, int, int> T3;

int H, W;
bool field[20][20];
bool visited[20][20];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = {1, 0, -1, 0};

int calc(int sx, int sy, int ex, int ey) {
	queue<T3> q;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)visited[i][j] = false;
	visited[sx][sy] = true;
	q.push(T3(sx, sy, 0));
	while (q.size()) {
		auto tmp = q.front(); q.pop();
		int x = get<0>(tmp), y = get<1>(tmp);
		int dis = get<2>(tmp);
		if (x == ex && y == ey) {
			return dis;
		}
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 || ny < 0 || nx >= H || ny >= W) continue;
			if (!field[nx][ny] || visited[nx][ny]) continue;
			visited[nx][ny] = true;
			q.push(T3(nx, ny, dis + 1));
		}
	}
	return 114514;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string tmp;
		cin >> tmp;
		for (int j = 0; j < W; j++) {
			if (tmp[j] == '.')field[i][j] = true;
		}
	}
	
	int ans = 0;
	for (int sx = 0; sx < H; sx++) {
		for (int sy = 0; sy < W; sy++) {
			if (!field[sx][sy])continue;
			for (int ex = 0; ex < H; ex++) {
				for (int ey = 0; ey < W; ey++) {
					if (!field[ex][ey])continue;
					if (sx == ex && sy == ey)continue;
					ans = max(ans, calc(sx, sy, ex, ey));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
/**
 * Created by hiramekun at 00:40 on 2020-05-22.
 */

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10));
    for (ll i = 1; i <= n; ++i) {
        string strn = to_string(i);
        cnt[strn.front() - '0'][strn.back() - '0']++;
    }
    ll ans = 0;
    rep(i, 10) rep(j, 10) ans += cnt[i][j] * cnt[j][i];
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int[] a = new int[10000];
        for(int i = 0; i < 10000; i++){
            a[i] = scan.nextInt();
            if(a[i] == 0)
            break;
            System.out.println("Case " + (i+1) + ": " +a[i]);
        }
    }
}


Measured memory_bytes: 41560
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   int a, b;
   cin >> a >> b;

   int ans = a * b;

   if(sz(to_string(a)) == 1 and sz(to_string(b)) == 1){
      cout<<ans;
      exit(0);
   }
      
   cout<<-1;

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a, i = 1;
        while( (a = scanner.nextInt()) != 0){
            System.out.println("Case " + i + ": " + a);
            i++;
        }
        scanner.close();
    }
}


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

ll solve() {
    ll N;
    cin >> N;
    if ( N & 1 ) return 0;
    ll n = N/2;
    ll c = 0;
    while ( n > 0 ) {
        c += n/5;
        n /= 5;
    }
    return c;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,n) for(long long i=a;i<=n;++i)
#define dbg1(a,b,c) cout<<"\n->"<<a<<" "<<b<<" "<<c<<"\n"; 
#define dbg2(a,b,c) cout<<"\n--"<<a<<" "<<b<<" "<<c<<"\n"; 
using namespace std;

typedef long long ll;
typedef long double ld;

ll mod=(ll)1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

    ll n,a[200005];
    vector<ll> push;
    cin>>n;
    rep(i,0,n-1) cin>>a[i];
	bool pos=true;
    ll cur=-1;
    rep(i,0,n-1){
        if(a[i]>i || (a[i]>cur && a[i]!=cur+1)){pos=false;break;}
        if(a[i]>cur){
            cur=a[i];
        }
        else{
            push.pb(cur);
            cur=a[i];
        }
    }
    push.pb(a[n-1]);
    if(!pos || a[0]!=0){
        cout<<-1;
    }
    else{
        ll ans=0;
        rep(i,0,(ll)push.size()-1){
            ans+=push[i];
        }
        cout<<ans;
    }
    return 0;
}

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

#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 FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi x(n);
	REP(i, n)cin >> x[i];
	int l; cin >> l;

	vvi v(n, vi(20));
	REP(i, n) {
		int c = upper_bound(ALL(x), x[i] + l) - x.begin();
		v[i][0] = c - 1;
	}
	FOR(j,1, 20) {
		REP(i, n) {
			int k = v[i][j - 1];
			if (k == n)v[i][j] = n;
			else {
				v[i][j] = v[v[i][j - 1]][j - 1];
			}
		}
	}
	int q; cin >> q;

	REP(i, q) {
		int l = 0, r = n;
		int a, b;
		cin >> a >> b; a--; b--;

		if (a > b)swap(a, b);
		while (r - l > 1) {
			int mid = (r + l) / 2;
			int p = a;
			REP(i, 20) {
				if (p == n)break;
				if ((1 << i) & mid) {
					p = v[p][i];
				}
			}
			if (p >= b)r = mid;
			else l = mid;
		}
		cout << r << endl;
	}
}

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

using namespace std;
typedef unsigned long long int ull;

ull gcd(ull a, ull b)
{
    if (b==0)
        return a;
    return gcd(b, a%b);
}
ull findlcm(ull arr[], ull n)
{
    ull ans = arr[0];
    for (int i=1; i<n; i++){
        ull g=gcd(arr[i], ans) ;
        ans = (arr[i]/g)*ans;

    }
    return ans;
}
int main()
{
    ull n,a[105],ans;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    ans=findlcm(a,n);
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int M=100001;
struct pt{double x,y;};
double cross(pt o,pt a,pt b){return (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);}
bool ptcomp(pt a,pt b){return make_pair(a.x,a.y)<make_pair(b.x,b.y);}
pt p[M];
vector<pt>hull;
int n;
void makeUB()
{
	hull.push_back(p[0]);
	for(int i=1;i<n;i++)
	{
		while(hull.size()>1 && cross(hull[hull.size()-2],hull.back(),p[i])>0)
			hull.pop_back();
		hull.push_back(p[i]);
	}
}
void makeLB()
{
	int hs=hull.size();
	for(int i=n-2;i>=0;i--)
	{
		while(hull.size()>hs && cross(hull[hull.size()-2],hull.back(),p[i])>0)
			hull.pop_back();
		hull.push_back(p[i]);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i].x>>p[i].y;
	sort(p,p+n,ptcomp);
	makeUB();//upper bound
	makeLB();//lower bound
	//cout<<"here"<<endl;
	//hullmaked
	cout<<hull.size()-1<<endl;
	int zp=0;
	for(int i=hull.size()-1;i>0;i--)
		if(hull[i].y<hull[zp].y)
			zp=i;
		else if(hull[i].y==hull[zp].y && hull[i].x<hull[zp].x)
			zp=i;
	for(int i=zp;i>0;i--)
		cout<<hull[i].x<<" "<<hull[i].y<<endl;
	for(int i=hull.size()-1;i>zp;i--)
		cout<<hull[i].x<<" "<<hull[i].y<<endl;
	return 0;
}

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

ll neutral=0;
struct fenewicktree
{
    vector<ll> bit;
    ll n;
    fenewicktree(ll n)
    {
        //zero based-indexing
        this->n =n;
        bit.assign(n,neutral);

        // one based idexing
        // this->n=n+1;
        // bit.assign(n+1,neutral);
    }
    void build(vector<ll> &v)
    {
        for(int i=0;i<v.size();i++)
            add(i,v[i]);
    }

    ll sum(ll r)
    {
        ll ret=0;
        // zero based indexing
        for(;r>-1;r= (r&(r+1))-1)
        {
            //cout<<" sum "<<r<<endl;
            ret+=bit[r];
        }

        // one based
        // for(++r;r>0;r-= (r& -r))
        //     ret+=bit[r];
        return ret;

    }

    ll sum(ll l,ll r)
    {
        return sum(r)-sum(l-1);
    }

    void add(ll idx,ll delta)
    {
        //zero based
        for(;idx<n;idx=(idx|(idx+1)) )
        {
            //cout<<" add2 "<<idx<<endl;
            bit[idx]+=delta;
        }

        //one based
        // for(++idx;idx<n;idx+= (idx& -idx))
        //     bit[idx]+=delta;
    }
    void show()
    {
        for(auto a:bit) cout<<a<<" ";
        cout<<endl;
    }

};

bool comp(pair<ll,pair<ll,ll>> &p1,pair<ll,pair<ll,ll>> &p2)
{
    return p1.second.second<p2.second.second;
}

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

    ll n,q; cin>>n>>q;
    ll arr[n];for(int i=0;i<n;i++) cin>>arr[i];
    vector<pair<ll,pair<ll,ll>>> v(q);
    for(int tt=0;tt<q;tt++)
    {
        cin>>v[tt].second.first>>v[tt].second.second;
        v[tt].second.first--;
        v[tt].second.second--;
        v[tt].first=tt;
    }
    sort(v.begin(),v.end(),comp);
    //for(auto a:v) cout<<a.second.first<<" "<<a.second.second<<endl;
    ll k=0;
    fenewicktree ft(500001);
    ll last[600001]; memset(last,-1,sizeof last);
    map<ll,ll> mp;
    for(int i=0;i<n &&k<v.size();i++)
    {
        if(last[arr[i]]!=-1)
        {
            ft.add(last[arr[i]],-1);
        }
        last[arr[i]]=i;
        ft.add(i,1);
        while(k<v.size() && i== v[k].second.second)
        {
            mp[v[k].first] =ft.sum(v[k].second.first,v[k].second.second);
            k++;
        }
        //ft.show();
    }
    for(int i=0;i<v.size();i++) cout<<mp[i]<<endl;
    return 0;
}


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

 
int main(){
     
    string a, b;
    cin >> a >> b;
    if(a < b){
        cout << "<"<< endl;
        return 0;
    }
    if(a > b){
        cout << ">" << endl;
        return 0;
    }
    cout << "="<< endl;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}





void solve(){
	ll X,K,D;
	 cin >> X >> K >> D;
    if (X < 0) X = -X;
    if (D <= X / K) X -= K * D;
    else {
        ll tims = X / D;
        X -= tims * D;
        K -= tims;
        if (K % 2) X = abs(X - D);
    }
    cout << X << endl;


return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int a, b;
    while (cin >> a >> b, a or b) {
        if (a > b) swap(a, b);
        cout << a << " " << b << "\n";
    }
    return 0;
}


Measured memory_bytes: 3112
let quick_sort (a : (int * char * int) array) cmp =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let partition p r =
    let rec exchange = function
      | (i, j) when j = r -> swap i r; i
      | (i, j) when cmp a.(j) a.(r) <= 0 -> swap i j; exchange (i + 1, j + 1)
      | (i, j) -> exchange (i, j + 1) in
    exchange (p, p) in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let rec doit i =
    if i = n then true
    else if (fun (xi, _, xd) (yi, _, yd) -> xd = yd && xi > yi) a.(i-1) a.(i) then false
    else doit (i + 1) in
  doit 1

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let read i =
    match split_on_char ' ' (read_line ()) with
    | [c; d] -> (i, c.[0], int_of_string d)
    | _ -> exit 1 in
  let a = Array.init n read in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 9112
import math
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
capacity = [a, b, c, d, e]

min = capacity[0]
for i in range(0, 5):
    if capacity[i] < min:
        min = capacity[i]


print("{}".format(math.ceil(N/min)+4))


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

const int N = 3e5 + 5;

#define die() exit(0 * puts("No"));

int A[N], n;

void solve(int x) {
  if(x == n + 1) return;
  if(A[x] == x) {
    solve(x + 1);
    return;
  }
  int y;
  for(y = x; y <= n; y += 2) {
    if(A[y + 1] != y + 1 || A[y + 2] == y + 2) break;
  }
  if(y == n + 1) y -= 2;
  if(x == y) die();
  vector <int> L, R;
  L.clear(), R.clear();
  for(int i = x; i <= y; i += 2) {
    if(A[i] > i) L.push_back(A[i]);
    else R.push_back(A[i]);
    if(A[i] < x || A[i] > y) die();
  }
  for(int i = 0; i < (int) L.size() - 1; ++ i) if(L[i] > L[i + 1]) die();
  for(int i = 0; i < (int) R.size() - 1; ++ i) if(R[i] > R[i + 1]) die();
  solve(y + 1);
}

main(void) {
  cin >> n;
  for(int i = 1; i <= n; ++ i) scanf("%d", &A[i]);
  solve(1);
  puts("Yes");
  return 0;
}


Measured memory_bytes: 34176
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
odd = Counter(v[0::2])
even = Counter(v[1::2])
odd["$"] = 0
even["#"] = 0
ans = 0
if odd.most_common()[0][0] == even.most_common()[0][0]:
    if odd.most_common()[1][1] > even.most_common()[1][1]:
        ans = n - odd.most_common()[1][1] - even.most_common()[0][1]
    else:
        ans = n - odd.most_common()[0][1] - even.most_common()[1][1]
else:
    ans = n - odd.most_common()[0][1] - even.most_common()[0][1]
print(ans)

Measured memory_bytes: 24544
import Control.Applicative
import Text.Printf
import Debug.Trace

qsort :: [Int]->[Int]
qsort [] = []
qsort (x:xs) = qsort left ++ [x] ++ qsort right
               where
                 left = filter (<=x) xs
                 right = filter (>x) xs

solve :: [Int]->[Char]
solve l = let l_sorted = qsort l in
            if (last l_sorted) < (sum $ init l_sorted) then "Yes"
            else "No"

main :: IO ()
main = do
  n <- getLine
  l <- fmap (read :: String -> Int) . words <$> getLine
  putStrLn $ solve l


Measured memory_bytes: 508
function main(input: string) {
  const lines = input.trim().split('\n')

  const [n] = lines[0].split(' ').map(Number)
  const h = lines[1].split(' ').map(Number)
  let ok = true
  let v = 0
  h.forEach(hi => {
    if (v <= hi) {
      v = hi
    } else if (v > hi + 1) {
      ok = false
    }
  })
  console.log(ok ? 'Yes' : 'No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 17816
import sys
input = sys.stdin.readline
import numpy as np
n, m, q = map(int, input().split())
dp = np.zeros((n+1, n+1), dtype=np.int64)
for _ in range(m):
  l, r = map(int, input().split())
  dp[l, r] += 1
dp = np.cumsum(dp, axis=1)
dp[::-1] = np.cumsum(dp[::-1], axis=0)
for _ in range(q):
  p, q = map(int, input().split())
  print(dp[p, q])

Measured memory_bytes: 18480
def f():
    n, m = map(int, input().split())
    a = [list(input()) for i in range(n)]
    b = [list(input()) for j in range(m)]
    for p in range(n - m + 1):
        for q in range(n - m + 1):
            cnt = 0
            for x in range(m):
                for y in range(m):
                    if a[x+p][y+q] == b[x][y]:
                        cnt += 1
                        if cnt == m*m:
                            return "Yes"
                    else:
                        break
    return "No"
print(f())

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> m;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  vector<int> v;
  set_symmetric_difference(begin(a), end(a), begin(b), end(b), inserter(v, end(v)));
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << "\n";
  }
  return 0;
}



Measured memory_bytes: 6472
N = int(input())
tmp = N % 10

if tmp == 2 or tmp == 4 or tmp == 5 or tmp == 7 or tmp == 9:
    print('hon')
elif tmp == 0 or tmp == 1 or tmp == 6 or tmp == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9044
n,Ma, Mb = map(int, input().split())
dp=[[[1000000]*510 for i in range(510)] for j in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    a, b, c = map(int, input().split())
    for j in range(410):
        for k in range(410):
            dp[i][j][k]=min(dp[i-1][j][k], dp[i][j][k])
            p=j+a
            q=k+b
            dp[i][p][q]=min(dp[i][p][q], dp[i-1][j][k]+c)
ans=1000000
for i in range(1, 410//max(Ma, Mb)+1):
    ans=min(dp[n][i*Ma][i*Mb], ans)
if ans==1000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 125404
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  std::vector<long> A(3);

  std::cin >> A[0];
  std::cin >> A[1];
  std::cin >> A[2];

  long K;

  std::cin >> K;

  std::sort(A.begin(), A.end());

  A[2] <<= K;

  long ans = 0;

  for (auto const& a : A)
    ans += a;

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,p,f[2505],ans;
struct data{
	int x,y,v;
}a[5005];
void solve(){
	for(int i=0;i<n*2;i++)
		for(int j=1;j<=m;j++){
			int x=a[j].x,y=a[j].y,v=a[j].v;
			if(f[x]==-1e18)continue;
			if(f[x]+v>f[y])f[y]=i<n-1?f[x]+v:1e18;
		}
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&p);
	for(int i=1;i<n;i++)f[i]=-1e18;
	for(int i=1;i<=m;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].v),a[i].x--,a[i].y--,a[i].v-=p;
	solve();ans=f[n-1];
	printf("%lld\n",ans!=1e18?max(0ll,ans):-1);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int inf=1e9;
pair<int,int> v[400010];
vector<int> poz[200010];

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,max1=0,min1=inf,max2=0,min2=inf,a,b;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a,&b);
        v[2*i-1]={a,i};
        v[2*i]={b,i};
        if(a<b) swap(a,b);
        max1=max(max1,a);
        min1=min(min1,a);
        max2=max(max2,b);
        min2=min(min2,b);
    }
    long long sol=1LL*(max1-min1)*(max2-min2);
    sort(v+1,v+1+2*n);
    for(int i=1;i<=2*n;i++) poz[v[i].second].push_back(i);
    a=b=2;
    int nr=0;
    for(int i=1;i<=2*n;i++)
    {
        for(;nr<n && b<2*n;b++)
            if(poz[v[b].second][0]==b || poz[v[b].second][0]<a) nr++;
        if(nr<n) break;
        sol=min(sol,1LL*(v[2*n].first-v[1].first)*(v[b-1].first-v[a].first));
        nr--;
        if(poz[v[a].second][0]==a && poz[v[a].second][1]<b) nr++;
        a++;
    }
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 14336
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- inpi toDbl
  print $ solve xs

solve :: [Double] -> Double
solve xs = last ys - head ys
  where ys = sort xs
    
toDbl :: String -> Double
toDbl s = read s

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents

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

typedef long long ll;
typedef pair<long, long> pll;

vector<ll> enum_div(ll n){
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


int main(){
  ll N;
  cin >> N;
  
  vector<ll> e;
  e = enum_div(N);
  
  ll min_digit = 11*11;
  for(auto x : e){
    ll y = N / x;
    string X = to_string(x);
    string Y = to_string(y);
    ll tmp = max(X.size(), Y.size());
    if(tmp < min_digit){
      min_digit = tmp;
    }
  }
  cout << min_digit << endl;
}

Measured memory_bytes: 256
import bisect
N=int(input())
A=list(map(int,input().split()))

D={}
for i in range(N):
    if A[i] not in D:
        D[A[i]]=1
    else:
        D[A[i]]+=1
        
D[0]=0
#print(D)
D=list(D.values())

D.sort()
#print(D)
B=[D[0]]
for i in range(1,len(D)):
    B.append(B[-1]+D[i])
D=D+[10**15]

#print(D)
#print(B)
cnt=N
for i in range(1,N+1):
    for j in range(N+1):
        C=bisect.bisect_left(D,cnt+0.1)
        if i*cnt<=B[C-1]+cnt*(len(B)-1-C+1):
            print(cnt)
            break
        else:
            cnt-=1

Measured memory_bytes: 119452
n = int(input())
 
graph = [[] for x in range(n)]
 
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((b, c))
    graph[b].append((a, c))
 
q, k = map(int, input().split())
k -= 1
 
costs = [0 for x in range(n)]
que = []
que.append((k, 0))
while que:
    now, cost = que.pop()
    costs[now] = cost
    for node in graph[now]:
        if graph[node[0]] is not None:
            que.append((node[0], cost + node[1]))
    graph[now] = None
 
result = ""
for i in range(q):
    x, y = map(int, input().split())
    result += str(costs[x - 1] + costs[y - 1])
    result += "\n"
print(result)

Measured memory_bytes: 45852
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  string S; cin >> S;
  int N = S.size();
  string zenhan, kouhan;
  for (int i = 0; i < (N - 1) / 2; ++i){
    zenhan += S[i];
  }
  for (int i = (N + 3) / 2 - 1; i < N; ++i){
    kouhan += S[i];
  }
  string r_S, r_zenhan, r_kouhan;
  r_S = S;
  r_zenhan = zenhan;
  r_kouhan = kouhan;
  reverse(r_S.begin(), r_S.end());
  reverse(r_zenhan.begin(), r_zenhan.end());
  reverse(r_kouhan.begin(), r_kouhan.end());
  if (S == r_S && zenhan == r_zenhan && kouhan == r_kouhan) cout << "Yes" << endl;
  else cout << "No" << endl;
  //cout << zenhan << " " << kouhan << endl;
  //cout << r_zenhan << " " << r_kouhan << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n,k;
    int sum=0;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<k;i++){
        sum+=v[i];
    }
    cout<<sum;
}


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

int main(){
  char s[100];
  string t;
  t="";
  ll i,a;
  cin >> s;
  a=strlen(s);
  for(i=0;i<a;i++){
    t+="x";
  }
  cout << t;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	H := nextInt()
	W := nextInt()
	a := make([]string, H)
	for i := 0; i < H; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}

	for i := 0; i < H+2; i++ {
		fmt.Print("#")
		if i > 0 && i < H+1 {
			fmt.Print(a[i-1])
		} else {
			for j := 0; j < W; j++ {
				fmt.Print("#")
			}
		}
		fmt.Println("#")
	}
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll x;
    cin >> x;

    drop( (x / 11) * 2 + (x % 11 >= 7) + (x % 11 >= 1));

    return 0;
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   int n;
   cin >> n;
   ll ans=1;
   ll last=1;
   vector<ll> v(n);
   for(int i=0;i<n;i++){
      cin >> v[i];
   }
   sort(all(v));
   if(v[0]==0){cout << 0;return;}
   else{
      for(int i=0;i<n;i++){
        if(last>ans*v[i]){cout << -1;return;}
        last=ans;
        ans*=v[i];
      }
   }
   if(ans<=1000000000000000000)
   cout << ans;
   else cout << -1;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


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

int main() {
  int a;
  int b1;
  int b2;
  int c;
  int s;
  cin >> s;
  a = s % 10;
  b1 = ( s % 100 - a ) ;
  b2 = b1 / 10;
  c =  ( s - b1 - a ) / 100;
  int kai;
  kai = a + b2 + c;
  cout << kai << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    string s;
    cin >> s;
    auto n = s.size();
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for (ll i = 0; i < n; i = i + 2) {
        if (s[i] != 'h' || s[i+1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int a, b, x, y;
	cin >> a >> b;
	y = b - 2*a;
	y = y / 2;
	x = a - y;
	if (x < 0)cout << "No" << endl;
	else if (y < 0)cout << "No" << endl;
	else if (x + y != a)cout << "No" << endl;
	else if (2 * x + 4 * y != b)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
int BIT[200010];
std::vector<LL> S;
LL N, K;
LL A[200010];
LL sum, ans;

void update(int n, int x) {
	for (int i = n; i <= N; i += i & -i) {
		BIT[i] += x;
	}
}
int getsum(int n) {
	int ss = 0;
	for (int i = n; i > 0; i -= i & -i) {
		ss += BIT[i];
	}
	return ss;
}

int main() {
	std::cin >> N >> K;
	for (LL i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		sum += tmp;
		LL add = i * K;
		A[i] = sum - add;
		S.emplace_back(A[i]);
		if (A[i] >= 0)ans++;
	}
	std::sort(S.begin(), S.end());
	for (int i = 1; i <= N; i++) {
		auto it = std::upper_bound(S.begin(), S.end(), A[i] - 1);
		A[i] = it - S.begin() + 1;
	}
	for (int i = 1; i <= N; i++) {
		ans += getsum(A[i]);
		update(A[i], 1);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
ll comb(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }

    ll ans[n];
    ll sum = 0;

    ll temp = 0;
    rep(i, n) {
        if (i % 2 == 0) {
            temp += a[i];
        } else {
            temp -= a[i];
        }
    }

    ans[0] = temp;
    sum = temp;

    repd(i, 1, n) {
        sum = a[i - 1] * 2 - sum;
        ans[i] = sum;
    }

    rep(i, n) { cout << ans[i] << " "; }

    cout << endl;
    return 0;
}

ll comb(ll a, ll b) {
    if (a < b) {
        return 0;
    }

    ll v[a + 1][a + 1] = {};

    rep(i, a + 1) {
        v[i][0] = 1;
        v[i][i] = 1;
    }

    repd(k, 2, a + 1) {
        repd(j, 1, k) { v[k][j] = v[k - 1][j - 1] + v[k - 1][j]; }
    }

    return v[a][b];
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 2816