akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n) {
        double a;
        cin >> a;
        sum += 1/a;
    }
    double ans = 1/sum;
    cout << ans << endl;
}

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

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

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

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

int main(){
    int N, M;
    cin >> N >> M;
    int ans = (N * (N - 1) / 2) + (M * (M - 1) / 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main 
{
	public static void main(String[] args) throws IOException
	{
		int q=ni();
		while(q-->0)
		{
			long a=ni(),b=ni();
			long te=a*b;
			long mid=(2*(long)Math.sqrt(a*b))-10;
			mid=Math.max(mid, 0);
			while(((mid+1)/2)*((mid+2)/2)<te)
			{
				mid++;
			}
			if(a==b)
				mid++;
			pr(mid-2);
		}
		System.out.println(ans);
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=false;
	static Reader in=new Reader();
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[][]nim(int n, int m){int a[][]=new int[n][m];for(int i=0; i<n; i++)for(int j=0; j<n; j++)a[i][j]=ni();return a;}
	static int[] ria(int n){int a[]=new int[n];for(int i=0; i<n; i++){a[i]=rn.nextInt(100);p(a[i]+" ");}pr();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static node[] graph(int n) {
		node[] ho=new node[n];
		for(int i=0; i<n; i++)
			ho[i]=new node();
		return ho;
	}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}
class node
{
	List<Integer> adj=new ArrayList<Integer>();
}

Measured memory_bytes: 25044
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define Rep(i,a) for(int i = 0; i < (a); i++)
#define rep(i,a,b) for(int i = (a); i <= (b); i++)//(a)!
#define dep(i,a,b) for(int i = (a); i >= (b); i--)
#define ab(a) ((a) > 0 ? (a) : -(a))
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 510, inf = 1e9 - 1;
int s[N][N];
int main() {
	int n, m, a, b; scanf("%d%d%d%d",&n,&m,&a,&b);
	if (n % a == 0 && m % b == 0) printf("No\n");
	else {
		printf("Yes\n");
		int t = inf / (a * b);
		s[a - 1][b - 1] = - t * (a * b - 1) - 1;
		Rep(i,a) Rep(j,b) if (i < a - 1 || j < b - 1) s[i][j] = t;
		Rep(i,n) Rep(j,m) printf("%d%c",s[i % a][j % b],(j == m - 1 ? '\n' : ' '));
	}
	return 0;
}

Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var L = new List<Edge>();
		Array.Sort(P, (p,q) => p.X.CompareTo(q.X) == 0 ? p.Y.CompareTo(q.Y) : p.X.CompareTo(q.X));
		for(int i=0;i<N-1;i++){
			L.Add(new Edge(P[i].Idx, P[i+1].Idx, Math.Min(Math.Abs(P[i+1].X - P[i].X), Math.Abs(P[i+1].Y - P[i].Y))));
			L.Add(new Edge(P[i+1].Idx, P[i].Idx, Math.Min(Math.Abs(P[i+1].X - P[i].X), Math.Abs(P[i+1].Y - P[i].Y))));
		}
		Array.Sort(P, (p,q) => p.Y.CompareTo(q.Y) == 0 ? p.X.CompareTo(q.X) : p.Y.CompareTo(q.Y));
		for(int i=0;i<N-1;i++){
			L.Add(new Edge(P[i].Idx, P[i+1].Idx, Math.Min(Math.Abs(P[i+1].X - P[i].X), Math.Abs(P[i+1].Y - P[i].Y))));
			L.Add(new Edge(P[i+1].Idx, P[i].Idx, Math.Min(Math.Abs(P[i+1].X - P[i].X), Math.Abs(P[i+1].Y - P[i].Y))));
		}
		
		L.Sort( (p, q) => p.Cost.CompareTo(q.Cost));
		var UF = new UnionFind(N);
		long cost = 0;
		foreach(var e in L){
			if(UF.IsUnited(e.Fr, e.To)) continue;
			cost += e.Cost;
			UF.Unite(e.Fr, e.To);
		}
		Console.WriteLine(cost);
		
	}
	int N;
	Pair[] P;
	public Sol(){
		N = ri();
		P = new Pair[N];
		for(int i=0;i<N;i++){
			var d = ria();
			P[i] = new Pair(d[0],d[1],i);
		}
	}
	
	class Pair{
		public int X,Y,Idx;
		public Pair(int x, int y, int idx){
			X = x; Y = y; Idx = idx;
		}
	}
	class Edge{
		public int Fr, To, Cost;
		public Edge(int f, int t, int c){
			Fr = f; To = t; Cost = c;
		}
	}
	
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N=n_;
		parent=new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i]=i;
			mem[i]=1;
		}
		compo=N;
	}
	
	public int Parent(int a){
		if(parent[a]==a)return a;
		return parent[a]=Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a)==Parent(b);
	}
	
	public void Unite(int a,int b){
		a=Parent(a);b=Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a==b)return;
		parent[a]=b;
		mem[b]+=mem[a];
		compo-=1;
	}
	
	public bool IsRoot(int x){
		return x==parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i==0?"{0}":" {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


Measured memory_bytes: 41740
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int S[200];
int top=0;

void push(int x){
    top++;
    S[top]=x;
}

int pop(){
    top--;
    return S[top+1];
}


int main(){
    int x,a,b;
    char s[100];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            x=atoi(s);
            push(x);
        }
    }
    printf("%d\n",pop());
    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define N 100005
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/


bool check(int mid){

  return false;
}

ll serch(ll ok,ll ng) {
	while (abs(ok-ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(){
  int n,cnt=0;
  string s;
  cin>>n>>s;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



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

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if((A1+A2+A3)>21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    int cnt = 0;
    int min = 1000000000;

    for(int i = 0; i < n; i++){
      a[i] = scan.nextInt();
      while(a[i] % 2 == 0){
        a[i] /= 2;
        cnt++;
      }
      min = Math.min(min, cnt);
      cnt = 0;
    }

    System.out.println(min);
  }
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int p[N];
long long s[N];
long long f[N];

void solve()
{
        cin >> n;
        int last = 0;
        long long ans = 0;
        for(int i = 1; i <= n; i++){
                long long x;
                cin >> x;
                s[i] = s[i - 1] + x;
                f[i] = f[i - 1] ^ x;
                p[i] = last + 1;
                for(int j = 1; j <= 21 && i - j >= 0; j++){
                        if((s[i] - s[i - j]) == (f[i] ^ f[i - j])){
                                ans += p[i - j + 1];
                        }
                }
                if(x == 0){
                        last++;
                        i--;
                        n--;
                }
                else{
                        last = 0;
                }
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 4224
N=int(input())
x=input()
def popcount(X,ones,count): 
    #print(count,bin(X),X,ones)
    if ones==0:
        return count
    else:
      
        X=X%ones
        
        count+=1
 
        ones=str(bin(X)).count("1")
        
        return popcount(X,ones,count)
 

    
GroundOnes=x.count("1")
GroundX=int(x,2)

if GroundOnes>1:
    CaseOne= GroundX%(GroundOnes-1)
else:
    CaseOne=2

CaseZero= GroundX%(GroundOnes+1)

TwoPowerCaseOne=[]
TwoPowerCaseZero=[]

# if GroundOnes>1:
#     for j in range(N):
#       TwoPowerCaseOne.append(pow(2,(N-j-1) , (GroundOnes-1)))
#       TwoPowerCaseZero.append(pow(2**(N-j-1), (GroundOnes+1)))
# else:
#     for j in range(N):
#       TwoPowerCaseZero.append(pow(2**(N-j-1), (GroundOnes+1)))
  
    
for i in range(N):
    
    #CaseOne
    if x[i]=="1":
        ones=GroundOnes-1
        if ones>0:
            X=CaseOne-pow(2,N-i-1,ones)
        else:
            X=0
    #CaseZero
    else:
        ones=GroundOnes+1
        X=CaseZero+pow(2,N-i-1,ones)
            
 
    # print("for loop",i)
    # print("ones",ones)
    # print("new2bit",new2bit)
    #print(" ------ return --- ",popcount(X,ones,0))
    print(popcount(X,ones,0))

Measured memory_bytes: 78004
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

ans = sum(A[K:])
print(ans)

Measured memory_bytes: 21988
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N,K;
int a[100001];
int ans=1000000001;
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++)cin >> a[i];
	sort(a,a+N);
	for(int i=0;i<N-K+1;i++){
		ans=min(ans,a[i+K-1]-a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ll expo( ll base, ll exp, ll m=MOD )
{
    ll res = 1;
    while( exp > 0 )
    {
        if( exp&1 )
        {
            res *= base;
            res = mod(res,m);
        }
        base *= base;
        base = mod(base,m);
        exp /= 2;
    }
    res = mod(res,m);
    return res;
}

int main() 
{
    fastio();

    string s;
    cin>>s;
    int n = s.size();
    vector<int>nextl(n,-1),prevr(n,-1);
    // nextl[i] = index of next ( excluding i ) L
    // prevr[i] = index of previous ( excluding i ) R
    int pr = 0;
    for(int i=1;i<n;i++)
    {
        prevr[i] = pr;
        if( s[i] == 'R' ) pr = i;
    }
    int pl = n-1;
    for(int i=n-2;i>=0;i--)
    {
        nextl[i] = pl;
        if( s[i] == 'L' ) pl = i;
    }

    ll fin[n]={};
    for(int i=0;i<n;i++)
    {
        if( s[i] == 'L' )
        {
            int pr = prevr[i];
            int steps = i-pr;
            if( steps%2 )
                fin[pr+1]++;
            else
                fin[pr]++;
        }
        if( s[i] == 'R' )
        {
            int pl = nextl[i];
            int steps = pl-i;
            if( steps%2 )
                fin[pl-1]++;
            else
                fin[pl]++;
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<fin[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 2256
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container, std.typecons;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto eij = new DList!edge[](n);

  foreach (_1; n.iota) {
    auto rd = readln.splitter;
    auto i = rd.front.to!size_t; rd.popFront;
    auto k = rd.front.to!size_t; rd.popFront;
    foreach (_2; k.iota) {
      auto v = rd.front.to!size_t; rd.popFront;
      auto c = rd.front.to!int; rd.popFront;
      eij[i].insertBack(edge(v, c));
    }
  }

  auto wi = dijkstra(n, eij, 0);
  foreach (i, w; wi)
    writefln("%d %d", i, w);
}

alias Tuple!(size_t, "v", int, "w") edge;

int[] dijkstra(size_t n, DList!edge[] eij, size_t s)
{
  auto wi = new int[](n);
  wi[] = -1;

  auto hi = heapify!("a.w > b.w")(Array!edge(edge(s, 0)));
  while (!hi.empty) {
    auto es = hi.front; hi.removeFront;
    if (wi[es.v] >= 0) continue;
    wi[es.v] = es.w;

    foreach (et; eij[es.v]) {
      if (wi[et.v] >= 0) continue;
      wi[et.v] = min(wi[et.v], es.w + et.w);
      hi.insert(edge(et.v, es.w + et.w));
    }
  }

  return wi;
}

Measured memory_bytes: 2804
// abc153_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll H, N;
    cin >> H >> N;
//    vector<P> AB(N);
//    REP(i, N) cin >> AB[i].first >> AB[i].second;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    ll mx = *max_element(ALL(A));

    vector<ll> dp(H+mx, INF);
    dp[0] = 0;
    REP(i, N){
        REPN(j, A[i], H+mx){
            dp[j] = min(dp[j], dp[j-A[i]] + B[i]);
        }
//        print(dp);
    }

    ll ans = INF;
    REPN(i, H, H+mx){
        ans = min(ans, dp[i]);
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 384
from copy import deepcopy

def main():
    n, k = map(int, input().split())
    a = [int(x)-1 for x in input().split()]
    visited = set()
    i = 0
    cnt = 0
    # 途中で前に行ったところに行ったら終わり
    # kが小さくてcnt == kになってもおわり
    while True:
        if i in visited:
            break
        visited.add(i)
        cnt += 1
        i = a[i]
        if cnt == k:
            print(i+1)
            exit()
    k -= cnt
    period = list()
    period.append(i)
    i = a[i]
    # 何回で同じ場所に戻るか
    while True:
        if i == period[0]:
            break
        period.append(i)
        i = a[i]
    # 余り
    mod = k % len(period)
    ans = period[mod]
    print(ans+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 33108
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      int q;
      while(cin>>q&&q!=-1){
            double x=(double)q/2.0;
            while(1){
                  if(0.00001*q>abs(x*x*x-q))break;
                  x=x-((x*x*x-q)/(3.0*x*x));
            }
            printf("%.10f\n",x);
      }
}

Measured memory_bytes: 1196
import operator
class SegmentTree:
    def __init__(self, size, fn=operator.add, default=None, initial_values=None):
        """
        :param int size:
        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など
        :param default:
        :param list initial_values:
        """
        default = default or 0

        # size 以上である最小の 2 冪を size とする
        n = 1
        while n < size:
            n *= 2
        self._size = n
        self._fn = fn

        self._tree = [default] * (self._size * 2 - 1)
        if initial_values:
            i = self._size - 1
            for v in initial_values:
                self._tree[i] = v
                i += 1
            i = self._size - 2
            while i >= 0:
                self._tree[i] = self._fn(self._tree[i * 2 + 1], self._tree[i * 2 + 2])
                i -= 1

    def set(self, i, value):
        """
        i 番目に value を設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self._tree[x] = value

        while x > 0:
            x = (x - 1) // 2
            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])

    def add(self, i, value):
        """
        もとの i 番目と value に fn を適用したものを i 番目に設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self.set(i, self._fn(self._tree[x], value))

    def get(self, from_i, to_i=None, k=0, L=None, r=None):
        """
        [from_i, to_i) に fn を適用した結果を返す
        :param int from_i:
        :param int to_i:
        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ
        :param int L:
        :param int r:
        :return:
        """
        if to_i is None:
            return self._tree[self._size - 1 + from_i]

        L = 0 if L is None else L
        r = self._size if r is None else r

        if from_i <= L and r <= to_i:
            return self._tree[k]

        if to_i <= L or r <= from_i:
            return None

        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)
        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)
        if ret_L is None:
            return ret_r
        if ret_r is None:
            return ret_L
        return self._fn(ret_L, ret_r)

    def __len__(self):
        return self._size



from bisect import bisect_right
def resolve():
    N, D, A = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()
    X, _ = zip(*AB)
    D = 2*D

    seg = SegmentTree(N+10)
    ans = 0
    for i, (x, h) in enumerate(AB):
        h = -(-h // A)
        damage = seg.get(0, i+1)

        if h < damage:
            continue
        ans += h - damage
        seg.add(i, h-damage)
        seg.add(bisect_right(X, x + D), - h + damage)
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 135696
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

        int a,b,a1,b1,c;
        cin>>a>>b>>a1>>b1>>c;
        int x=0,x1,x3=0;
        if(b>b1)
		{
			x3=b-b1;
		}
		else
		{
			x=b1-b;
		}
		x1=a1-a;
		int ans=x1*60;
		ans=ans+x-x3;
		ans=ans-c;
		cout << ans << endl;


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    int N(in()), K(in());
    cout << N - K + 1 << endl; 
    return 0;
}




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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  
  int ans=0;
  for (auto d : a){
    while (d%2==0){
      d/=2;
      ans+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main()
{
	double A, B, C, D, E, F, X, Y, G , H;

	while(cin >> A >> B >> C >> D >> E >> F)
	{
		X=(C*E-F*B)/(A*E-D*B);
		Y=(A*F-D*C)/(A*E-D*B);

		if(X==0){
			X=0;
		}

		if(Y==0){
			Y=0;
		}

		printf("%.3f %.3f\n",X,Y);
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;


int main(){
    int n;
    cin >> n;
    int ans=0;
    while(n>0){
        if(n%10==2)ans++;
        n/=10;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int a,b,c,d;
  
  cin>>a>>b>>c>>d;
  
  if(a+b>c+d)
    cout<<"Left"<<endl;
  else if(a+b==c+d)
    cout<<"Balanced"<<endl;
  else 
    cout<<"Right"<<endl;
  
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)

	if (A < 10 && B < 10) console.log(A * B)
	else console.log(-1)
}

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


Measured memory_bytes: 21064
import sys
def input():
	return sys.stdin.readline().strip()


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = sum(B)
for i in range(N - 1):
	if A[i] + 1 == A[i + 1]:
		total += C[A[i] - 1]

print(total)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
lli imos[200005] = {};
void solve(long long N, long long D, long long A, std::vector<long long> X,
           std::vector<long long> H)
{
  vector<pair<lli, lli>> p;
  rep(i, N) p.emplace_back(X[i], H[i]);
  sort(p.begin(), p.end());
  lli cur = 0;
  lli ans = 0;
  rep(i, N)
  {
    lli y = p[i].first;

    cur += imos[i];
    //cout << y << " " << imos[i] << " " << cur << endl;
    lli rem = p[i].second - A * cur;

    if (rem > 0)
    {
      rem = (rem + A - 1) / A;
      cur += rem;
      ans += rem;
      int idx = std::upper_bound(p.begin(), p.end(), pair<lli, lli>(y + 2 * D, 1e9)) - p.begin();
      //cout << idx << endl;
      imos[idx] -= rem;
    }
  }
  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  long long A;
  scanf("%lld", &A);
  std::vector<long long> X(N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &X[i]);
    scanf("%lld", &H[i]);
  }
  solve(N, D, A, std::move(X), std::move(H));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    def cmb(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return (fact[n] * factinv[r] * factinv[n-r])%mod

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, N + 5):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
        
    loc=[-1]*N
    mu=[-1,-1]
    for i in range(N+1):
        if loc[a[i]-1]==-1:
            loc[a[i]-1]=i
        else:
            mu[0]=loc[a[i]-1]
            mu[1]=i
    N1=mu[0]
    N2=N-mu[1]
    
    for i in range(N+1):
        if i==0:
            print(N)
        else:   
            print((cmb(N+1,i+1,mod)-cmb(N1+N2,i,mod))%mod)
        
            
    
            
            
        


main()


Measured memory_bytes: 71824
#include <atcoder/maxflow>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
int main() {
	int N, M;
	cin >> N >> M;
	vector<string> S(N);
	for (auto& x : S) cin >> x;
	mf_graph<int> G(N * M + 2);
	for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) if (S[i][j] == '.') {
		if ((i+j) % 2 == 0) {
			G.add_edge(N*M, i*M+j, 1);
		} else {
			G.add_edge(i*M+j, N*M+1, 1);
		}
	}
	int di[] = {+1,-1, 0, 0};
	int dj[] = { 0, 0,+1,-1};
	for (int i = 0; i < N; ++ i) for (int j = 0; j < M; ++ j) if (S[i][j] == '.' && (i+j) % 2 == 0) {
		for (int k = 0; k < 4; ++ k) {
			int ii = i + di[k];
			int jj = j + dj[k];
			if (0 <= ii && ii < N && 0 <= jj && jj < M && S[ii][jj] == '.') {
				G.add_edge(i*M+j, ii*M+jj, 1);
			}
		}
	}
	cout << G.flow(N*M, N*M+1) << endl;
	for (auto e : G.edges()) if (e.from < N*M && e.to < N*M && e.flow > 0) {
		int i = e.from / M, j = e.from % M;
		int ii = e.to / M, jj = e.to % M;
		if (i == ii) {
			if (j > jj) swap(j, jj);
			S[i][j] = '>';
			S[i][jj] = '<';
		} else {
			if (i > ii) swap(i, ii);
			S[i][j] = 'v';
			S[ii][j] = '^';
		}
	}
	for (auto& x : S) cout << x << endl;
}


Measured memory_bytes: 5472
#include <bits/stdc++.h>
using namespace std;
long long _gcd;
int main () {
	int n;
	cin >> n;
	for (long long i = 1; i <= n; ++i) {
		for (long long j = 1; j <= n; ++j) {
			for (long long k = 1; k <= n; ++k) {
				_gcd += __gcd (__gcd (i, j), k);
			}
		}
	}
	cout << _gcd << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	cout << max(a+b,max(a+a-1,b+b-1)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main { 
	public static void main(String[] args) { 
	Scanner sc = new Scanner(System.in); 
	int cnt = sc.nextInt();	//count回数

		for (int i=1; i <= cnt; i++) {
			if (i % 3 == 0) {
				//3で割った余りが0なら出力
		        System.out.printf(" " + i);
			} else {
				//10で割った余りが3なら出力
				if (i % 10 == 3) {
					System.out.printf(" " + i);
				} else {
					String x = String.valueOf(i);
					if (x.contains("3")) {
						System.out.printf(" " + i);
					}
				}
			}
		}
		System.out.println("");
	}
}




Measured memory_bytes: 31404
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    int input;
    int buf = 0;
    long long answer = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> input;
        if (input == 0)
        {
            buf = 0;
        }
        answer += (input + buf) / 2;
        buf = (input + buf) % 2;
    }
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

int main(){

    int n;
    cin>>n;
    if(n==22)cout<<"Christmas Eve Eve Eve"<<endl;
    if(n==23)cout<<"Christmas Eve Eve"<<endl;
    if(n==24)cout<<"Christmas Eve"<<endl;
    if(n==25)cout<<"Christmas"<<endl;


    return 0;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(n: usize, vs: [i64; n]);
    let mut minus = 0;
    let mut nin = 1_000_000_009;
    use std::cmp;
    for v in &vs {
        let vv = *v;
        if vv < 0 {
            minus += 1;
        }
        nin = cmp::min(nin, vv.abs());
    }

    let ans: i64 = vs.iter().map(|&x| x.abs()).sum();
    if minus % 2 != 0 {
        println!("{}", ans - nin * 2);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4476
fun c83(args: Array<String>) {
    val (x, y) = args[0].split(" ").map { it.toLong() }
    var curr = x
    var ans = 0
    while (curr <= y) {
        ans++
        curr *= 2
    }
    println(ans)
}

fun main(args: Array<String>) {
    c83(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> p(n);

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

  int cnt = 0, num = 10000000;
  for (int i = 0; i < n; ++i) {
    num = min(num, p[i]);
    if (num == p[i]) {
      ++cnt;
    }
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a[3];
	int k;
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	cin>>k;
	rep(i,k)a[2]*=2;
	cout<<a[0]+a[1]+a[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    ll N;cin>>N;
    pair<ll,ll> info[N];
    rep(i,N)cin>>info[i].first>>info[i].second;
    sort(info,info+N);
    ll nowmax=info[0].first+info[0].second;
    ll count=1;
    rep(i,N-1){
        ll l=info[i+1].first-info[i+1].second,r=info[i+1].first+info[i+1].second;
        if(l<nowmax)nowmax=min(nowmax,r);
        else{
            count++;nowmax=r;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long 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 INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0,c-(a-b));


    return 0;
}

Measured memory_bytes: 3636
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve());
		Out.Flush();
	}
	long Solve()
	{
		var I = GL();
		long K = I[0], A = I[1], B = I[2], d = A - B;
		if (A >= K) return 1;
		if (d <= 0) return -1;
		var n = (K - B - 1) / d;
		return 2 * n + 1;
	}
}


Measured memory_bytes: 13268
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

long long DP_min(long long a, long long b) {
    if (a > b) {
        return a;
    }
    else {
    }
}

const long long INF = 1LL << 60;

int main() {
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size()-1; i++) {
        if (S.at(i) != S.at(i + 1)) {
            count++;
        }
    }
    cout << count << endl;  
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	LL n, a, b;
	cin >> n >> a >> b;
	LL l = (n - 1) * a + b;
	LL r = a + (n - 1) * b;
	cout << max(r - l + 1, 0LL) << endl;
}

Measured memory_bytes: 256
s = input()
c = "abcdefghijklmnopqrstuvwxyz"
a = len(s)
for i in c:
  sl = s
  count = 0
  while len(sl) != sl.count(i):
    nsl = ""
    for j in range(len(sl)-1):
      if sl[j] == i or sl[j+1] == i:
        nsl += i
      else:
        nsl += sl[j]
    sl = nsl
    count += 1
  a = min(a,count)
print(a)

Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin>>N>>M;
    vector<pair<long long,long long>>a(N);
    for(int i=0;i<N;i++){
        long long x,y;
        cin >>x>>y;
        a.at(i)=make_pair(x,y);
    }
    sort(a.begin(),a.end());
    long long summ=0;
    for(int i=0;i<N;i++){
         if(M-a.at(i).second>=0){
             M-=a.at(i).second;
             summ+=a.at(i).first*a.at(i).second;
         }
         else{
             summ+=M*a.at(i).first;
             break;
         }
    }
    cout<<summ<<endl;

}

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

	public class Main{

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			int type = sc.nextInt();
			int buy = sc.nextInt();
			int typeArray[] = new int[type];

			for(int i=0; i<typeArray.length; i++){
				typeArray[i]=sc.nextInt();
			}
			Arrays.sort(typeArray);

			int sum =0;
			for(int j=0; j<buy; j++){
				sum = sum + typeArray[j];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 30036
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
int main()
{
	int n;
	cin>>n;
	int t=n%10;
	if(t==3)cout<<"bon";
	else if(t==0||t==1||t==6||t==8)cout<<"pon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main()
{
  char s[200001],t[200001];
  long long i,n;
  n=0;
  scanf("%s", &s);
  scanf("%s", &t);
  
  for (i=0;i<=strlen(s);i++)
  {
    if (s[i] != t[i]) 
    {
      n+=1;
    }
  }
    printf("%lld",n);
    return 0;
}

Measured memory_bytes: 2496
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int H;
int W;

int A[30][30];


i64 dist[30][30][1000];

i64 INF = 1e18;

struct point{
  int x;
  int y;
  int times;
  bool operator<(const point& a) const{
    return false;
  }
};

int main(){
  cin >> H >> W;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      cin >> A[i][j];
    }
  }
  using P = pair<i64,point>;
  priority_queue<P,vector<P>,greater<P>> que;
  for(int i = 0;i < 30;i++) for(int j = 0;j < 30;j++) for(int k = 0;k < 1000;k++){
    dist[i][j][k] = INF;
  }
  dist[0][0][0] = 0;
  que.push({0,{0,0,0}});

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

  while(!que.empty()){
    P p = que.top();
    que.pop();

    int x = p.second.x;
    int y = p.second.y;
    int times = p.second.times;
    i64 d = p.first;

    if(dist[x][y][times] < d) continue;
    if(times > 910) continue;

    for(int i = 0;i < 4;i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(0 <= nx && nx < H && 0 <= ny && ny < W){
        i64 new_dist = A[nx][ny] * (1LL + 2 * times) + d;
        if(dist[nx][ny][times + 1] > new_dist){
          dist[nx][ny][times + 1] = new_dist;
          que.push({new_dist,{nx,ny,times + 1}});
        }
      }
    }
  }

  i64 res = 1e18;

  for(int i = 0;i < 1000;i++){
    res = min(res , dist[H - 1][W - 1][i]);
  }

  cout << res << endl;
}



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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main(){
    int K;
    cin >> K;
    int sum = 0;
    for(int i=1;i <= K; i++){
        for(int j=1;j <= K; j++){
            for(int k=1;k <= K; k++){
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
 int main() { ll a,b,c,d,i,j,k=0; vector<ll>v,x; cin>>a; for(i=1;i<=a;i++) {cin>>b;v.push_back(b);} x=v; sort(x.begin(),x.end()); if(x==v)cout<<"YES\n"; else{ for(i=0,j=0;i<a;i++,j++) { if(x[i]!=v[j])k++; } if(k<=2)cout<<"YES\n"; else cout<<"NO\n"; } }

Measured memory_bytes: 256
n, m = map(int, input().split())
matrics = [[0 for i in range(0, m)] for j in range(0, n)]
vectors = [[0 for i in range(0, 1)] for j in range(0, m)]
# print(matrics)
# print(vectors)
for i in range(0, n):
	matrics[i] = list(map(int, input().split()))
for i in range(0, m):
	vectors[i] = int(input())
# print(matrics)
# print(vectors)
for i in matrics:
	sum = 0
	for j in range(0, m):
		sum = sum + i[j] * vectors[j]
	print(sum)



Measured memory_bytes: 5976