akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#define inf  (int)1e18
#define EPS   1e-9
#define MOD 1000000007
#define all(k) k.begin(),k.end()
#define Pi 3.14159
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define ll  long long
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vc vector<char>
#define vl vector<ll>
#define vvl vector<vl>
#define vi vector<int>
#define vvi vector<vi>
#define vc vector<char>
#define vpl vector<pl>
#define vvc vector<vc>
#define mi map<int,int>
#define ml map<ll,ll>

#define umap unordered_map<int,int>
using namespace std;


void sol() {
	int k; cin >> k;
	string s = "ACL";
	rep(i, 0, k)
	cout << s;




}



int main() {


	int t = 1;


	// for (cin >> t; t; t--)
	sol();


	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long n,a,b;
void solve(){
    if(a+b>n+1||a*b<n){
        puts("-1");
        return ;
    }
    while(n>0){
        long long x=min(a,n-b+1);
        for(long long i=n-x+1;i<=n;i++)
            printf("%lld ", i);
        n-=x;
        b--;
    }
}
int main(){
    scanf("%lld%lld%lld",&n,&a,&b);
    solve();
    return 0;
}

Measured memory_bytes: 3796
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            WriteLine(n * n * n);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11092
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val k = sc.nextInt
    val ra =
      (0 until k).foldLeft(Rat(0, 1))((acc, _) => acc + Rat(1, sc.nextInt))
    sc.close()

    println(BigDecimal(ra.d) / BigDecimal(ra.n))
  }

  object Rat {
    def apply(a: BigInt, b: BigInt): Rat = {
      if (b == 0) throw new ArithmeticException
      val g = a gcd b
      val n = a * b.signum / g
      val d = b * b.signum / g
      new Rat(n, d)
    }
  }

  class Rat private (val n: BigInt, val d: BigInt) {
    def +(that: Rat): Rat = Rat(n * that.d + that.n * d, d * that.d)
  }
}

Measured memory_bytes: 26952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    ans.at(a-1) = i+1;
  }
  for(int x:ans){
    cout << x << ' ';
  }
}
    

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int main(){
  int n;
  cin>>n;
  while(n--){
    int score = 0;
    int out = 0;
    bool r1,r2,r3;
    r1=r2=r3=false;
    while(true){
      string s;
      cin>>s;
      if(s=="HIT"){
        if(r3)r3=false,++score;
        if(r2)r2=false,r3=true;
        if(r1)r1=false,r2=true;
        r1=true;
      }else if(s=="HOMERUN"){
        score += r1;
        score += r2;
        score += r3;
        score += 1;
        r1=r2=r3=false;
      }else if(s=="OUT"){
        ++out;
        if(out==3)break;
      }
    }
    cout<<score<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    long long A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    
    long long cost=A*X+B*Y;
    
    if(A+B>2*C){
        cost=min(X,Y)*C*2;
        if(X>=Y){
            cost+=min((X-Y)*A, C*(X-Y)*2);
        }else{
            cost+=min((Y-X)*B, C*(Y-X)*2);
        }
    }
    
    cout<<cost<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, n;

    scanf("%d", &n);
    
    int x[n];
    
    for (i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }

    for (i = n - 1; i > 0; i--){
        printf("%d ", x[i]);
    }

    printf("%d\n", x[0]);

    return (0);

}


Measured memory_bytes: 2688
#include<stdio.h>

int main(){
  int a = 0, b = 0, c = 0, x = 0, y = 0;
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
  int s = 0;
  int z = 0;

  if (x >= y){
    if(a + b <= 2*c){
      s = 1;
    }else if(2*c > a){
      s = 2;
    }else if(a >= 2*c){
      s = 3;
    }
  }else{
    if(a + b <= 2*c){
      s = 1;
    }else if(2*c > b){
      s = 4;
    }else if(b >= 2*c){
      s = 5;
    }
  }

  switch(s){
    case 1:
      z = a*x + b*y;
      break;
    case 2:
      z = a*(x-y) + 2*c*y;
      break;
    case 3:
      z = 2*c*x;
      break;
    case 4:
      z = b*(y-x) + 2*c*x;
      break;
    case 5:
      z = 2*c*y;
      break;
  }
  //printf("case %d ", s);
  printf("%d", z);

  return 0;
}


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

int main(){
	int n,x;
	cin >> n >> x;
	vector<int> m(n);
	
	int mi = __INT_MAX__;
	int total = 0;
	rep(i,n){
		cin >> m.at(i);
		mi = min(mi, m.at(i));
		x  -= m.at(i);
	}

	int count = x/mi;

	cout << n+count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> //ABC 154_a
using namespace std;
int main(){
	int A,B;
	string S,T,U;
	cin>>S>>T>>A>>B>>U;
	if(U==S)
		A--;
	else if(U==T)
		B--;
	cout<<A<<" "<<B;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto K = readln.chomp.to!int;
    long[] rnrn;
    void make(int i, long n, long l) {
        rnrn ~= n;
        if (i == 10) return;
        foreach (m; max(0, l-1)..min(10, l+2)) {
            make(i+1, n*10+m, m);
        }
    }
    foreach (i; 1..10) make(0, i, i);
    sort(rnrn);
    writeln(rnrn[K-1]);
}

Measured memory_bytes: 11004
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        cout<<char('1'+'9'-s[i]);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int R, G;

  std::cin >> R >> G;

  std::cout << 2 * G - R << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<string.h>
#include<functional>
#define int long long
#define P pair<int,int>
using namespace std;

int mincost[100000];
vector<P>rinsetu[100000];
struct E {
	int first, second, ID;
};
struct F {
	int cost, v, u;
};
bool operator <(E a, E b) {
	if (a.first != b.first)return a.first < b.first;
	return a.ID < b.ID;
}
int p[100000];//par
int r[100000];//rank
int find(int a) {
	if (p[a] == a)return a;
	return find(p[a]);
}
void unite(int a,int b) {
	int c = find(a), d = find(b);
	if (c == d)return;
	if (r[c] > r[d]) {
		p[d] = c;
	}
	else if (r[c] < r[d]) {
		p[c] = d;
	}
	else {
		r[c]++;
		p[d] = c;
	}
}
F c[200000];//???
int x[100000], y[100000], z[100000];
E n[100000];//????????¢?´¢???(S,G]
signed main() {
	int M, Q;//????\????
	int a, b; scanf("%lld%lld%lld%lld", &a, &b, &M, &Q);
	priority_queue<P, vector<P>, greater<P>>q;
	for (int d = 0; d < b; d++) {
		scanf("%lld%lld", &c[d].v, &c[d].u);
		int U; scanf("%lld", &U);
		c[d].v--; c[d].u--;
		rinsetu[c[d].v].push_back({ U,c[d].u });
		rinsetu[c[d].u].push_back({ U,c[d].v });
	}
	memset(mincost, 0x3f, sizeof(mincost));
	for (int i = 0; i < M; i++) {
		int R; scanf("%lld", &R);
		R--;
		mincost[R] = 0;
		q.push({ 0,R });
	}
	while (q.size()) {
		P t = q.top(); q.pop();
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > t.first + i.first) {
				mincost[i.second] = t.first + i.first;
				q.push({ mincost[i.second], i.second });
			}
		}
	}
	int count = 0;
	for (int i = 0; i < a; i++) {
		for (P j : rinsetu[i]) {
			if (i < j.second) {
				c[count++] = { min(mincost[i],mincost[j.second]),i,j.second };
			}
		}
	}
	sort(c, c + b, [](F a, F b) {if (a.cost != b.cost)return a.cost > b.cost; return a.v * 1000000 + a.u > b.v * 1000000 + b.u; });
	for (int i = 0; i < Q; i++) {
		scanf("%lld%lld", &x[i], &y[i]);
		x[i]--; y[i]--;
		n[i] = { 0,INT_MAX,i };
	}
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < a; j++) {//UF????????????
			p[j] = j;
			r[j] = 0;
		}
		sort(n, n + Q, [](E a, E b) {if (a.first != b.first)return a.first > b.first; return a.ID < b.ID; });
		int K = 0;
		for (int j = 0; j < Q; j++) {
			int T = (n[j].first + n[j].second) / 2;
			while (c[K].cost >= T&&K<b) {
				unite(c[K].u, c[K].v);
				K++;
			}
			if (find(x[n[j].ID])== find(y[n[j].ID])) {
				n[j].first = T;
			}
			else {
				n[j].second = T;
			}
		}
	}
	sort(n, n + Q, [](E a, E b) {return a.ID < b.ID; });
	for (int i = 0; i < Q; i++) {
		printf("%lld\n", n[i].first);
	}
}

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

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

    stack<char> st;
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (st.empty() || S[i] == st.top()) st.push(S[i]);
        else st.pop();
    }

    cout << N - st.size() << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    cin >> N >> K;
    int h;
    int ans = 0;
    rep (i, N)
    {
        cin >> h;
        if (h >= K) ++ans;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,b) for(int i=0;i<b;i++)
using namespace std;
string s[50];
int n,m;
signed main() {
    cin>>n;
    rep(i,n)cin>>s[i];
    rep(j,26) {
        m = 100;
        rep(i, n)m = min(m, (int) count(begin(s[i]), end(s[i]),(char)j+97));
        rep(i, m) cout <<(char)(j+97);
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	string a,b;
	cin >> a >> b;
	int ans = 1e8;
	for(int e=0;e<=sz(a)-sz(b);e++){
		int tot = 0;
		for(int p=e;p<e+sz(b);p++) if(a[p]!=b[p-e]) tot++;
		ans = min(ans,tot);
	}
	printf("%d",ans);
	return 0;
}


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

#define MAX_SIZE 1001
#define MAX_VALUE 10001

int solve(int* A, int n) {
    int B[MAX_SIZE];
    int T[MAX_VALUE];
    bool Check[MAX_SIZE];
    int s = MAX_VALUE;
    int ans = 0;
    
    // Tに各値の正しい位置の添え字を保存
    for(int i = 0; i < n; ++i) {
        B[i] = A[i];
        s = min(s, A[i]);
    }
    sort(B, B + n);
    for(int i = 0; i < n; ++i) {
        T[B[i]] = i;
    }
    
    for(int i = 0; i < n; ++i) {
        Check[i] = false;
    }
    
    for(int i = 0; i < n; ++i) {
        int an = 0;   // サイクルサイズ
        int S = 0;   // サイクル内の要素の合計値
        int m = MAX_VALUE;
        int cur = i;
        if(Check[cur]) {
            continue;
        }
        while(!Check[cur]) {
            Check[cur] = true;
            ++an;
            S += A[cur];
            m = min(m, A[cur]);
            cur = T[A[cur]];
        }
        ans += min((S + (an - 2) * m), (S + m + (an + 1) * s)); 
    }
    
    return ans;
}

int main(void) {
    int n;
    int A[MAX_VALUE];
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    
    cout << solve(A, n) << endl;
    
    return 0;
}


Measured memory_bytes: 3184
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 200005;

LL s1[N], s2[N], a[N], L, Ans;
int n;

LL f(int l,int r) {
	return s1[r] - a[l] * (r - l) - s1[l];
}

void Calc() {
	for (int i = 1; i <= n; ++i) s1[i] = s1[i - 1] + a[i], s2[i] = s2[i - 1] + (L - a[n - i + 1]);
	for (int i = 0; i < n; ++i) {
		LL now = a[i] * (n - i) + a[i];
		int cnt = (n - i) / 2;
		if ((n - i) % 2 == 0) 
			now += s2[cnt] * 2 + f(i, i + cnt) * 2 - (a[i + cnt] - a[i]);
		else 
			now += s2[cnt + 1] * 2 + f(i, i + cnt) * 2 - (L - a[n - cnt]);
//		puts("-------------------------------");
//		if (n & 1) {
//			cout << s2[cnt + 1] * 2 << " " << f(i, i + cnt) * 2 << " " <<  (L - a[n - cnt]) << " ";
//		}
//		else {
//			cout << s2[cnt] * 2 << " " <<  f(i, i + cnt) * 2 << " " << (a[i + cnt] - a[i]) << " ";
//		}
//		cout << now << "\n";
		
		Ans = max(Ans, now);
	}
}
int main() {
	L = read(); n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	Calc();
	for (int i = 1; i <= n; ++i) a[i] = L - a[i];
	reverse(a + 1, a + n + 1);
	Calc();
	cout << Ans;
	return 0;
}

Measured memory_bytes: 4992
import itertools
import math 
def C(n,r):
    if n-r < 0:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

n, m = map(int, input().split())
n = C(n,2)
m = C(m,2)
print(n+m)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10000000)


def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
        sys.exit()
    else:
        T1 = S[:N//2]
        T2 = S[N//2:]
        if T1 == T2:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38460
#include <iostream>
#include <string>
#include <ios>
#include <iomanip>
using namespace std;

int calc(int x,string s){
  string p = s.substr(x,3);
  int y = stoi(p);
  //cout << y << endl;
  if(y >= 753)
    return y - 753;
  else
    return 753 - y;
}

int main(void){
  string number;
  cin >> number;

  int l = number.length();
  //cout << l << endl;

  int min = 999;
  for(int i=0;i<l-2;i++){
    //cout << calc(i,number) << endl;
    if(min > calc(i,number))
      min = calc(i,number);
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;


int main()
{
	LL n, k;
	cin >> n >> k;

	vector<LL> s1;

	while (n) {
		s1.push_back(n%k);
		n /= k;
	}

	cout << s1.size() << "\n";
	
}

Measured memory_bytes: 256
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int n;
	cin >> n;
	ll t = 1;
	ll cnt = 1;
	ll max = 0;
	vector<ll> as(n+1);
	rep(i, n+1){
		ll a;
		cin >> a;
		as[i] = a;
		max += a;
	}
	rep(i, n+1){
		if(t<as[i]){
			cout << "-1" <<endl;
			return 0;
		}
		t = (t-as[i])*2;
		max -= as[i];
		if(t > max){
			t = max;
		}

		//cout << t << endl;
		cnt += t;
		//cout << cnt << endl;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb() scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
int t,n,m;
int a[maxn];
ll b[maxn];
int main(){
    ll sum=0;
    rusha();
    rep(i,1,n) b[a[i]]++;
    rep(i,1,n)
        sum+=(b[i]-1)*b[i]/2;
    rep(i,1,n){
        printf("%lld\n",sum-(b[a[i]]-1)*b[a[i]]/2+(b[a[i]]-2)*(b[a[i]]-1)/2);
    }
    return 0;
}


Measured memory_bytes: 3968
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::vector<int> primes;

int N, A[11111111], size;

const int NN = 10000000;


void dfs(int i, const std::vector<int>& a) {
  A[a.back()] = a.size();

#if 0
  std::cerr << "i=" << i << " s=" << a.back() << " a=";
  for (const auto& k : a)
    std::cerr << k << ' ';
  std::cerr << "primes[i]=" << primes[i] << std::endl;
#endif

  for (int k = i; k < size; k ++) {
    long long s = 1LL * a.back() * primes[k];

    if (s > N)
      break;

    std::vector<int> aa(a);

    aa.reserve(aa.size() * 2);

    for (const auto& l : a)
      aa.push_back(l * primes[k]);

    std::sort(ALL(aa));
    
    aa.erase(std::unique(ALL(aa)), std::end(aa));

    dfs(k, aa);
  }
}


template <typename T>
std::vector<T> divisibles(T n) {
  std::vector<T> a;

  for (T i = 1, r; i * i <= n; i ++)
    if (n % i == 0) {
      a.push_back(i);

      if ((r = n / i) != i)
        a.push_back(r);
    }

  std::sort(ALL(a));

  a.erase(std::unique(ALL(a)), std::end(a));

  return a;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::vector<bool> is_prime(NN + 1, true);

  is_prime[0] = is_prime[1] = false;

  for (int i = 2; i * i <= NN; i ++)
    if (is_prime[i])
      for (int k = i + i; k <= NN; k += i)
        is_prime[k] = false;

  primes.reserve(777777);

  for (int i = 2; i <= NN; i ++)
    if (is_prime[i])
      primes.push_back(i);

  size = primes.size();

  memset(A, -1, sizeof(A));

  A[1] = 1;

  std::cin >> N;

  for (int i = 0; i < size; i ++) {
    int p = primes[i];

    if (p > N)
      break;

    std::vector<int> a = {1, p};

    dfs(i, a);
  }

  long long S = 0;

  for (int i = 1; i <= N; i ++)
    S += 1LL * i * A[i];

  std::cout << S << std::endl;
  
  return 0;
}



Measured memory_bytes: 50396
N = int(input())
SP = []
for i in range(1, N+1):
    Si, Pi = map(str, input().split())
    SP.append([Si, int(Pi), i])

SP = sorted(SP, key=lambda x: x[1], reverse=True)
SP = sorted(SP, key=lambda x: x[0])
for sp in SP:
    print(sp[2])


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int d,n;cin>>d>>n;){
		vi ts(d),as(n),bs(n),cs(n);
		rep(i,d) cin>>ts[i];
		rep(i,n) cin>>as[i]>>bs[i]>>cs[i];
		
		vvi dp(d,vi(n,-1));
		rep(i,n) if(as[i]<=ts[0] && ts[0]<=bs[i])
			dp[0][i]=0;
		repi(i,1,d) rep(j,n) if(as[j]<=ts[i] && ts[i]<=bs[j])
			rep(k,n) if(dp[i-1][k]!=-1)
				dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(cs[j]-cs[k]));
		cout<<*max_element(all(dp[d-1]))<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1344
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<unordered_map>
#include<queue>

#define inf 0x3f3f3f3f
#define ii pair<int,int> 
#define iii pair<int, ii>
#define pb push_back

const int maxn = 5010;


using namespace std;
typedef vector<int> vi;
int arr[3];

int main () {
	int a, b, k;
	cin >> a >> b >> k;
	if ( b < a) swap (a, b );
	
	for(int i = a ; i <= b ;i++){
		if (i >= a + k  && i <= b - k ) continue;
		
		cout<< i << '\n';
	}
	cout<<'\n';
}
	
	 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ab=0;
  int ba=0;
  for(int i=0;i<a;i++)
    ab=ab*10+b;
  for(int i=0;i<b;i++)
    ba=ba*10+a;
  cout<<(a<b?ba:ab)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


const ll MOD = 1e9 + 7;
int main() {
    ll N, M;
    cin >> N >> M;

    ll l = M - N;
    vector<ll> a(N+1);
    a[1] = l;
    a[2] = l * l + l + 1;
    rep(i, 3, N+1){
        ll tmp = ((l + i - 1) * a[i - 1]) % MOD;
        ll tmp1 = ((i - 1) * a[i-2]) % MOD;
        a[i] = (tmp + tmp1) % MOD;
    }
    ll tmp = 1;
    rep(i, M - N + 1, M+1) tmp = (tmp * i) % MOD;
    ll ans = (a[N] * tmp) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6652
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = sum(b)
j = m
ans = 0
for i in range(n+1):
    while j > 0 and t > k:
        j -= 1
        t -= b[j]
    if t > k:
        break
    ans = max(ans, i+j)
    if i == n:
        break
    t += a[i]

print(ans)

Measured memory_bytes: 118776
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    S = list(map(int, readline().split()))
    T = list(map(int, readline().split()))

    dp = [1] * (M + 1)

    for i in range(N):
        dp_prev = dp[:]
        for j in range(M):
            if S[i] == T[j]:
                dp[j + 1] = (dp_prev[j + 1] + dp[j]) % MOD
            else:
                dp[j + 1] = (dp_prev[j + 1] + dp[j] - dp_prev[j]) % MOD

    print(dp[M])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9364
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(Number)

  const n = input[0]
  const a = input[1]
  const b = input[2]
  const arr = []
  for (let i = 1; i <= n; i++) {
    const tmp = i
      .toString()
      .split('')
      .map(Number)
      .reduce((a, b) => a + b)
    // console.log(tmp)
    if (tmp >= a && tmp <= b) arr.push(i)
  }
  // console.log(arr)
  const ans = arr.reduce((a, b) => a + b)

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		for(int k=0; k<m; k++){
		  for(int i=0; i<m; i++){
		    for(int j=0; j<m; j++){
		      if(C[i][j]>C[i][k]+C[k][j]){
			C[i][j] = C[i][k]+C[k][j];
		      }
		      if(T[i][j]>T[i][k]+T[k][j]){
			T[i][j] = T[i][k]+T[k][j];
		      }
		    }
		  }
		}

		int k;
		cin >> k;

		for(int i=0; i<k; i++){
		  int p, q, r;
		  cin >> p >> q >> r;

		  if(r==0){
		    cout << C[p-1][q-1] << endl;
		  }
		  else{
		    cout << T[p-1][q-1] << endl;
		  }
		}
	}

	return 0;
}


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

#define _1E9 1000000000

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    if (s == _1E9) {
        bool flag = false;
        for (int i = 0; i < k; i++) {
            if (flag) {
                cout << " " << _1E9;
            } else {
                cout << _1E9;
            }
            flag = true;
        }
        for (int i = 0; i < n - k; i++) {
            if (flag) {
                cout << " " << 1;
            } else {
                cout << 1;
            }
            flag = true;
        }
    } else {
        bool flag = false;
        for (int i = 0; i < k; i++) {
            if (flag) {
                cout << " " << s;
            } else {
                cout << s;
            }
            flag = true;
        }
        for (int i = 0; i < n - k; i++) {
            if (flag) {
                cout << " " << _1E9;
            } else {
                cout << _1E9;
            }
            flag = true;
        }
    }

    return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  int A,B,X;;
  cin >> A >> B >> X;
  
  if(A<=X && X<=(A+B)) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(n)]
b=[int(input()) for i in range(m)]
c=[0 for i in range(n)]
for i  in range(n):
    for j in range(m):
        c[i]+=A[i][j]*b[j]

print(*c, sep='\n')


Measured memory_bytes: 6024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3+7;
const int maxm = 2e6+7;
const ll mod = 1e9+7;
int n,m,k;

ll f[maxn], inv[maxn], sinv[maxn];
ll cc(ll a,ll b){
    if(a<b)return 0;
    if(a==b || b==0)return 1;
    return f[a]*sinv[a-b]%mod*sinv[b]%mod;
}
int main()
{ 
    scanf("%d%d", &n,&k);
    m=n-k;
    f[0] = 1;
    for(int i=1;i<maxn;i++)f[i] = f[i-1]*i%mod;
    inv[0] = inv[1] = 1;
    for(int i=2;i<maxn;i++)inv[i] = inv[mod%i]*(mod-mod/i)%mod;
    sinv[0] = 1;
    for(int i=1;i<maxn;i++)sinv[i] = sinv[i-1]*inv[i]%mod;
    for(int i=1;i<maxn;i++)assert(f[i] * sinv[i] % mod == 1);

    for(int i=1;i<=k;i++){
        printf("%lld\n", cc(m+1, i) * cc(k-1, i-1)%mod);
    }
    



    return 0;
}


Measured memory_bytes: 256
import itertools
def f(a, b):
    return max(len(str(a)), len(str(b)))
def p(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

def main():
    N = int(input())
    l = p(N)
    if len(l) < 2:
        print(f(N, 1))
    else:
        w = len(l)
        ans = len(str(N))
        for i in itertools.product([0, 1], repeat=w):
            a = b = 1
            for j in range(w):
                if i[j] == 0:
                    a *= l[j]
                else:
                    b *= l[j]
            ans = min(ans, f(a, b))
        print(ans)
if __name__ == '__main__':
    main()


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

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

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

int dp[50001];

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

	int coins[20];
	int n, m;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> coins[i];
	}

	sort(coins, coins + m);

	for (int i = 0; i <= n; i++)
	{
		dp[i] = i;
	}

	for (int i = 1; i < m; i++)for (int j = 1; j <= n; j++)
	{
		if (coins[i] <= j)
		{
			dp[j] = min(dp[j], dp[j - coins[i]] + 1);
		}
	}

	cout << dp[n] << endl;
	
	return 0;
}


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

int judge(char s1,char s2){
  if(s1=='#'&&s2=='#') return 0;
    return 1;
}
int judge2(char s1,char s2,char s3){
  if(s1!='#' && s2!='#'){
    if(s3!='#') return 1;
  }
  else return 0;}

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  //  char *s;
  //  s=(char*)malloc(sizeof(char)*n);
  cin>>s;
  int e,buf;
  buf=0;
  if(c<d) e=d;
  else if(c>d){
    e=c;
    buf++;
  }
  int ans=0;
  int ans2=0;
  for(int i=a;i<e;i++){
    if(judge(s[i-1],s[i])==0){
	ans++;
    }}
  if(buf>0){
      for(int j=b-1;j<d;j++){
	if(judge2(s[j-1],s[j],s[j+1])==1){
	  ans2++;
	}}}
  
    if(ans==0){
      if(buf==0){
      cout<<"Yes"<<endl;
    }
      else if(ans2>0){
	cout<<"Yes"<<endl;
      }
      else {
	cout<<"No"<<endl;
      }}
    else {
      cout<<"No"<<endl;
    }
  //  cout<<s[3]<<endl;
  return 0;
}


Measured memory_bytes: 640
import sys
N,K=map(int,sys.stdin.readline().split())
A=sorted([int(e) for e in sys.stdin.readline().split()] for _ in range(N))
x,y=zip(*A)
Y=sorted(y)
r=(x[-1]-x[0])*(Y[-1]-Y[0])
for i in range(N):
 for j in range(i+1,N):
  for k in range(N):
   for l in range(k+1,N):
    ly=Y[k];ry=Y[l];q=(x[j]-x[i])*(ry-ly)
    if r>q and K<=(j-i+1) and K<=sum(ly<=y[z]<=ry for z in range(i,j+1)): r=q
print(r)

Measured memory_bytes: 53468
from itertools import permutations
A1, A2, A3 = (int(i) for i in input().split())

res=1000
for (a, b, c) in permutations([A1,A2,A3], 3):
    intermediate = abs(a-b)+abs(b-c)
    if(intermediate< res):
        res=intermediate

print(res)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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

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

  int n = sz(s);

  int ans = 0;
  rep(i,n-1) {
    if (s[i] != s[i+1]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

  ll N;
  cin >>N;
  ll sum=0;
  for (int i=1; i<N+1; i++){
  	if (i%3!=0 && i%5!=0) sum += i;
  
  }
  cout <<sum;

	
}


Measured memory_bytes: 3632
function AtCoder_step(N,As)
    sum=0
    maxh=As[1]
    for i in 2:N
        dif = max(maxh-As[i],0)
        if(dif==0)
            maxh=As[i]
        end
        sum+=dif
    end
    println(sum)
    return 
end

N=parse(Int,readline())
Astr=readline()
As=parse.(Int,split(Astr))

AtCoder_step(N,As)


Measured memory_bytes: 200256
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;

int main(){
	timefaster;
	int a , b , c;
	cin >> a >> b >> c;
	if(a == b && b == c) cout << "No" << endl;

	else if(a == b || b == c|| c == a) cout << "Yes" << endl;
	else cout << "No"; 
}// Aksay sila

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define N 200010
using namespace std;

struct query{ll l,r,v;} a[N];
ll n,m,cnt,t[N<<2],lt[N<<2];

bool cmp(query a,query b) { return a.r<b.r; }

void push(int x)
{
    t[x<<1]+=lt[x];
    lt[x<<1]+=lt[x];
    t[x<<1|1]+=lt[x];
    lt[x<<1|1]+=lt[x];
    lt[x]=0;
}

void update(int x,int l,int r,int a,int b,ll v)
{
    if(b<l || a>r) return;
    if(l==a && r==b)
    {
        t[x]+=v;
        lt[x]+=v;
        return;
    }
    push(x);
    int m=(l+r)/2;
    update(2*x,l,m,a,min(b,m),v);
    update(2*x+1,m+1,r,max(a,m+1),b,v);
    t[x]=max(t[2*x],t[2*x+1]);
}

ll query(int x,int l,int r,int a,int b)
{
    if(b<l || a>r) return 0;
    if(l==a && r==b) return t[x];
    push(x);
    int m=(l+r)/2;
    return max(query(2*x,l,m,a,min(b,m)),query(2*x+1,m+1,r,max(a,m+1),b));
}

int main()
{
    cin>>n>>m;
    FOR(i,0,m) cin>>a[i].l>>a[i].r>>a[i].v;
    sort(a,a+m,cmp);
    FOR(i,1,n+1)
    {
        update(1,1,n,i,i,query(1,1,n,1,i));
        while(a[cnt].r==i)
        {
            update(1,1,n,a[cnt].l,a[cnt].r,a[cnt].v);
            cnt++;
        }
    }
    cout<<max(t[1],0ll)<<'\n';

    return 0;
}

Measured memory_bytes: 17408
<?php
$N = trim(fgets(STDIN));
$L = explode(" ", trim(fgets(STDIN)));
sort($L);
$ans = 0;
for($i = 0; $i < 2 * $N; $i++) {
  if($i % 2 == 0) $ans += $L[$i];
}
print($ans);
?>

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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e5 + 1;
const int INF = 2e9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,cnt[14] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		cnt[a / 400]++;
	}
	int mi = 0;
	for(int i = 0;i <= 7;i++){
		if(cnt[i]) mi++;
	}
	if(mi) cout << mi << " ";
	else cout << 1 << " ";
	for(int i = 8;i <= 12;i++) mi += cnt[i];
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var s string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &s)
	chars := strings.Split(s, "")

	var K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	set := NewStrSet()
	for i := 0; i < len(chars); i++ {
		for k := 1; k <= K && i+k <= len(chars); k++ {
			str := strings.Join(chars[i:i+k], "")
			set.Add(str)
		}
	}
	//fmt.Println(set.Entries())

	records = make([]Record, set.Size())
	index := 0
	for str, _ := range set.Entries() {
		records[index] = Record{str}
		index++
	}
	sort.Sort(records)
	//fmt.Println(records)
	fmt.Println(records[K-1].str)

}

var records Records

type Record struct {
	str string
}

type Records []Record

func (r Records) Len() int {
	return len(r)
}
func (r Records) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r Records) Less(i, j int) bool {
	return r[i].str < r[j].str
}

type StringSet struct {
	set map[string]struct{}
}

func NewStrSet() *StringSet {
	return &StringSet{
		set: make(map[string]struct{}),
	}
}

func (s *StringSet) Add(str string) {
	s.set[str] = struct{}{}
}

func (s *StringSet) Contains(str string) bool {
	_, e := s.set[str]
	return e
}

func (s *StringSet) Size() int {
	return len(s.set)
}

func (s *StringSet) IsEmpty() bool {
	return s.Size() == 0
}

func (s *StringSet) Entries() map[string]struct{} {
	return s.set
}


Measured memory_bytes: 2560
import sys
K=int(input())
a = [7%K]
for k in range(1, K+1):
    temp = (a[k-1]*10+7)%K
    a.append(temp)
for k in range(K+1):
    if a[k]==0:
        print(k+1)
        sys.exit()
print(-1)


Measured memory_bytes: 48380
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool prime[1000005];
ll n;

int main(void){
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
	scanf("%lld",&n);
	int ans=0;
	for(int i=2;i<=1000000;i++){
		if(!prime[i])continue;
		int cnt=0;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		for(int k=1;;k++){
			if(cnt>=k){
				ans++;
				cnt-=k;
			}else{
				break;
			}
		}
	}
	if(n!=1LL){
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4764
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := r(), r()

	ab := make(map[int]int, n)
	keys := make([]int, 0, n)
	for i := 0; i < n; i++ {
		a, b := r(), r()
		if _, ok := ab[a]; !ok {
			ab[a] = b
			keys = append(keys, a)
		} else {
			ab[a] += b
		}
	}
	sort.Ints(keys)

	var count int
	var ans int64
	for _, k := range keys {
		switch {
		case count+ab[k] < m:
			count += ab[k]
			ans += int64(k) * int64(ab[k])
		case count+ab[k] == m:
			ans += int64(k) * int64(ab[k])
			fmt.Println(ans)
			return
		case count+ab[k] > m:
			ans += int64(k) * int64(m-count)
			fmt.Println(ans)
			return
		}
	}
}


Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<stdio.h>
#include<vector>
#include<set>
#include<utility>
#include<ctype.h>
#include<ctime>
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
# define ll long long
using namespace std;
int gcd(int a,int b){
    int r;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int GCD(int a,int b)
{
    if(a==0) return b;
    else return GCD(b%a,a);
}
long long int power(long long int a,long long int b){
    long long int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}
int palindrome(char *s,int len)
{
    int i,j,k,count=0,c=0;
    for(i=0,j=len-1;i<len,j>=0;i++,j--){
        if(s[i]==s[j]) count++;
    }
	if(count==len) return 1;
    	else return 0;
}
long long int binary(char *s,long long int len)
{
    long long int i,j,k,r=0,p=0,num;
    for(i=len-1;i>=0;i--){
        num=s[i]-'0';
        r+=(num*power(2,p));
        p++;
    }
    return r;
}
int binary_search(int *ara,int size,int n)
{
    int high,mid,low;
    low=0;
    high=size-1;
    while(low<=high){
        mid=(low+high)/2;
        if(ara[mid]==n){
            return 1;
        }
        else if(n>ara[mid]) low=mid+1;
        else if(n<ara[mid]) high=mid-1;
    }
    return -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int i,j,k,n,T,q,s,sum=0;
	string s1,s2;
	cin>>k>>s;
    for(i=0;i<=k;i++){
        for(j=0;j<=k;j++){
            if(s-i-j>=0 && s-i-j<=k) sum++;
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
require 'digest/md5'

H_LEN = 100000
h = Array.new(H_LEN)
len = gets.to_i
while l = gets
  command, str = l.split(' ')
  h_index = Digest::MD5.hexdigest(str).hex % H_LEN
  if command == 'insert'
    h[h_index] = h[h_index] ? h[h_index].push(str) : [str]
  elsif command == 'find'
    found = false
    if h[h_index]
      h[h_index].each do |v|
        if v == str
          found = true
          break
        end
      end
    end
    puts(found ? 'yes' : 'no')
  end
end


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

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

  int N; cin >> N;
  vector<ll> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  vector<ll> SUM(N, 0);
  SUM[0] = A[0];
  for (int i = 1; i < N; i++) {
    SUM[i] = SUM[i - 1] + A[i];
  }

  for (int i = N - 1; i >= 0; i--) {
    if (SUM[i - 1] * 2 < A[i]) {
      cout << (N - i) << '\n';
      return 0;
    }
  }

  cout << N << '\n';
  return 0;
}

Measured memory_bytes: 1792
package main

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

func reverse(s string) string{
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1{
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var(
		str, p string
		n, a, b int
	)
	fmt.Scan(&str, &n)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		x := scanner.Text()
		xl := strings.Fields(x)
		// fmt.Println(xl)
		switch xl[0] {
		case "replace":
			a, _ = strconv.Atoi(xl[1])
			b, _ = strconv.Atoi(xl[2])
			p = xl[3]
			// fmt.Println(p)
			str = str[:a] + p + str[b+1:]
		case "reverse":
			a, _ = strconv.Atoi(xl[1])
			b, _ = strconv.Atoi(xl[2])
			str = str[:a] + reverse(str[a:b+1]) + str[b+1:]
			// fmt.Println(str)
		case "print":
			a, _ = strconv.Atoi(xl[1])
			b, _ = strconv.Atoi(xl[2])
			// fmt.Println(str)
			fmt.Println(str[a:b+1])
		}
	}
}


Measured memory_bytes: 1336