akhauriyash/Code-Regression huggingface dataset:
# ABC084C - Snuke Festival
from bisect import bisect_left, bisect_right

n = int(input())
lst_a = sorted(list(map(int, input().rstrip().split())))
lst_b = sorted(list(map(int, input().rstrip().split())))
lst_c = sorted(list(map(int, input().rstrip().split())))
lgth = len(lst_c)
ans = 0
for i in lst_b:
    ans += bisect_left(lst_a, i) * (lgth - bisect_right(lst_c, i))
print(ans)

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

int arr[10];
int n,m,q;
int a[50];
int b[50];
int c[50];
int d[50];
int ret=0;

void makearray(int ind,int val) {
    if (ind==n+1) {
        int sum=0;
        for(int i=0;i<q;i++) {
            if (arr[b[i]]-arr[a[i]]==c[i]) {
                sum+=d[i];
            }
        }
        ret=max(ret,sum);
        return;
    }
    for(int i=val;i<=m;i++) {
        arr[ind]=i;
        makearray(ind+1,i);
    }
}

int main(void) {
    scanf("%d %d %d\n",&n,&m,&q);
    for(int i=0;i<q;i++) {
        scanf("%d %d %d %d\n",&a[i],&b[i],&c[i],&d[i]);
    }
    makearray(1,1);
    printf("%d",ret);
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	string s;cin>>s;
	int n=s.size();
	int rm=0,r=0;
	for(int i=0;i<n;++i)
		if(s[i]=='R')++r;
		else{
			rm=max(rm,r);
			r=0;
		}
	rm=max(rm,r);
	cout<<rm<<endl;
}


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

int main() 
{
    int k, x;
    cin >> k >> x;

    for(int i=x-k+1; i<=x+k-1; i++) {
        printf("%d%c", i, i==x+k-1? '\n':' ');
    }
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

answer = 0
for i in range(1, N + 1):
    if len(graph[i]) == 0:
        answer += 1
    else:
        flag = 1
        for ni in graph[i]:
            if H[ni] >= H[i]:
                flag = 0
                break
        if flag:
            answer += 1

print(answer)

Measured memory_bytes: 107116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  string s; cin >> s;
  if (count(ALL(s), 'R') > N/2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef int Read ; // Here to change the type of numbers
inline Read Readin() {
	Read K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline Read Min( Read A , Read B ) { return A < B ? A : B ; }
inline Read Max( Read A , Read B ) { return A > B ? A : B ; }
inline Read Abs( Read A ) { return A < 0 ? -A : A ; }

const int MaxN = 200000 + 5 ;
int N ;
inline int L( int Num ) {
	int Ans = 0 ;
	while( Num ) ++Ans , Num >>= 1 ;
	return Ans ;
}
map<int,int> Set ;
int main() {
	N = Readin() ;
	int Ans = 0 ;
	for(register int i = 0 ; ++i <= N ; Set[Readin()]++ ) ;
	while( Set.size() ) {
		map<int,int>::iterator It = Set.end() , Find ;
		--It ;
		register int Num = (*It).first , Mat = ( 1 << L( Num ) ) - Num ;
		if( --((*It).second) == 0 ) Set.erase( Num ) ;
		if( ( Find = Set.find( Mat ) ) != Set.end() ) {
			if( --((*Find).second) == 0 ) Set.erase( Mat ) ;
			++Ans ;
		}
	}
	return not printf( "%d\n" , Ans ) ;
}


Measured memory_bytes: 9600
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		
		double ans = 0;
		for(int i = 0;i < n;i++){
			double num = sc.nextDouble();
			if(sc.next().equals("JPY")){
				ans += num;
			}else{
				ans  += num * 380000;

			}
			
		}
		System.out.println(ans);
		
	}
}



Measured memory_bytes: 23252
from collections import defaultdict

class Graph:

    def __init__(self,vertices):
        self.V = vertices
        self.graph = []

    def addEdge(self,s,t,w):
        self.graph.append([s,t,w])

    def find(self, parent, i):
        if(parent[i] == i):
            return i
        return self.find(parent, parent[i])

    def union(self, parent, rank, x, y):
        xroot = self.find(parent, x)
        yroot = self.find(parent, y)

        if rank[xroot] < rank[yroot]:
            parent[xroot] = yroot
        elif rank[xroot] > rank[yroot]:
            parent[yroot] = xroot

        else :
            parent[yroot] = xroot
            rank[xroot] += 1

    def KruskalMST(self):
        sum = 0
        result = []
        i = 0
        e = 0

        self.graph = sorted(self.graph, key=lambda item:item[2])
        parent = []
        rank = []
        for node in range(self.V):
            parent.append(node)
            rank.append(0)

        while e < self.V - 1:
            s, t, w = self.graph[i]
            i+=1
            x = self.find(parent, s)
            y = self.find(parent, t)

            if x != y:
                e = e + 1
                result.append([s, t, w])
                self.union(parent, rank, x, y)

        for s,t,weight in result:
            sum +=  weight

        print(sum)

if __name__ == "__main__":
    V, E = (int(z) for z in input().split())
    g = Graph(V)

    for i in range(E):
        s, t, w = (int(z) for z in input().split())
        g.addEdge(s, t, w)

    g.KruskalMST()



Measured memory_bytes: 26996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int K = Integer.parseInt(arr[1]);
        out.println(K == 1 ? 0 : N - K);
        out.close();
    }
}


Measured memory_bytes: 21332
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val words = listOfString()

    if (words[0].substring(words[0].count()-1) == words[1].substring(0, 1) && 
        words[1].substring(words[1].count()-1) == words[2].substring(0, 1)) {
        println("YES")
    } else {
        println("NO")
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36084
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

signed main()
{
    int K,N;
    cin>>N>>K;

    vector<int> memo[100000];
    for(int i=0;i<N;i++)
    {
        int t,d;
        cin>>t>>d;
        t--;
        memo[t].emplace_back(d);
    }

    vector<ll> q1,q2;
    for(int i=0;i<N;i++)
    {
        sort(memo[i].rbegin(),memo[i].rend());
        if(memo[i].size())
        {
            q1.emplace_back(memo[i][0]);
            for(int j=1;j<memo[i].size();j++)q2.emplace_back(memo[i][j]);
        }
    }
    sort(rbegin(q1),rend(q1));
    sort(rbegin(q2),rend(q2));
    for(int i=1;i<q2.size();i++)q2[i]+=q2[i-1];
    
    ll ret=0,make=0;
    for(int i=0;i<K&&i<q1.size();i++)
    {
        make+=q1[i];
        ll rest=K-i-1;
        if(rest<=q2.size())
        {
            ll odd=rest<=0?0:q2[rest-1];

            ll tmp=make+odd+1LL*(i+1)*(i+1);
            if(ret<tmp)ret=tmp;
        }
    }

    cout<<ret;
    return 0;
}

Measured memory_bytes: 6904
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            String sign = in.next();
            int b = in.nextInt();
            if (sign.equals("+")) {
                out.println(a + b);
            } else {
                out.println(a - b);
            }
        }

    }
}



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

using namespace std;


int main(){

    //freopen("input.txt","r",stdin);

    int N,X;
    int arr[101234];

    cin >> N >> X;

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

    int cur = 0;
    long long int ans = 0;


    for(int i=0; i<N; i++){

        if(cur + arr[i]>X){
           ans += cur + arr[i] - X;
           cur = X - cur;
        }else{
           cur = arr[i];
        }

        //cout << "Cur : " << cur << " " << " Arr :: " << arr[i] << " Sum: " << ans << endl;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>ans  = new ArrayList<>();
        
        int cou = 0;
        for(int i=0; i<S.length(); i++) {
        if(ss[i]=='A' || ss[i]=='C' || ss[i]=='G' || ss[i]=='T') {
        	cou++;
        }else {
        	ans.add(cou);
                cou = 0;
        }
        }
        ans.add(cou);
        Collections.sort(ans,Collections.reverseOrder());
        System.out.println(ans.get(0));
    }
}


Measured memory_bytes: 35704
/* https://atcoder.jp/contests/abc087/tasks/arc090_a */

#include <iostream>
#include <vector>

int N;
std::vector<std::vector<int>> A;

void solve()
{
  std::vector<std::vector<int>> cum_sum(2, std::vector<int>(N));

  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      int pre = j == 0 ? 0 : cum_sum.at(i).at(j-1);

      cum_sum.at(i).at(j) = A.at(i).at(j) + pre;
    }
  }

  int max_num_candies = 0;

  for (int i = 0; i < N; ++i) {
    int pre = i == 0 ? 0 : cum_sum.at(1).at(i-1);

    int num_candies_above = cum_sum.at(0).at(i);
    int num_candies_under = cum_sum.at(1).at(N-1) - pre;

    max_num_candies = std::max(max_num_candies, num_candies_above+num_candies_under);
  }

  std::cout << max_num_candies << std::endl;

  return;
}

int main(int argc, char *argv[])
{
  // Input
  std::cin >> N;

  A = std::vector<std::vector<int>>(2, std::vector<int>(N));

  for (std::vector<int>& v: A)
    for (int& e: v)
      std::cin >> e;

  // Output
  solve();

  return 0;
}


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

using namespace std;

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

  int n, a;
  cin >> n;
  if (n == 1) {
    cin >> a;
    cout << a << endl;
  } else {
    vector<int> res(n);
    int p, t;
    if (n%2 == 0) {
      p = (n+1)/2;
      t = -1;
    } else {
      p = n/2; 
      t = 1;
    }
    for (int i = 1; i <= n; ++i) {
      cin >> a;
      res[p] = a;
      p += i*t;
      t *= -1;
    }
    for (auto &r: res) cout << r << " ";
    cout << endl;
  }

  return 0;
}



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

using namespace std;
using ll = long long;

const ll md = 998244353;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

using MInt = mod::MInt<long long, md>;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  vector<pair<int, int>> vp(k);
  for (auto &p : vp) {
    cin >> p.first >> p.second;
  }

  vector<MInt> dp(n);
  dp[0] = 1;
  dp[1] = -1;
  for (int i = 0; i < n; ++i) {
    if (i != 0) {
      dp[i] += dp[i - 1];
    }

    for (auto &p : vp) {
      if (i + p.first < dp.size()) {
        dp[i + p.first] += dp[i];
      }

      if (i + p.second + 1 < dp.size()) {
        dp[i + p.second + 1] -= dp[i];
      }
    }
  }

  cout << dp.back().Get() << '\n';

  return 0;
}

Measured memory_bytes: 4820
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
#define F first
#define S second
using namespace std;

int main(){

  int n;
  string s;
  int d,k;
  typedef pair < int, pair < string, int > > P;
  vector < P > vec;
  P p;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s >> d;
    p.F = s.size();
    p.S.F = s;
    p.S.S = d;
    vec.push_back( p );
  }

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

  for(int i=0;i<n-1;i++){
    if(vec[i].S.F == vec[i+1].S.F) vec[i+1].S.S += vec[i].S.S;
    else cout << vec[i].S.F << " " << vec[i].S.S << endl;
  }

  cout << vec[n-1].S.F << " " << vec[n-1].S.S << endl;

}

Measured memory_bytes: 1796
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

using Weight = int;

struct Edge {
	size_t from;
	size_t to;
	Weight cost;
	Edge(size_t t, Weight c) : to(t), cost(c) {}
	Edge(size_t f, size_t t, Weight c) : from(f), to(t), cost(c) {}
	bool operator<(const Edge& rhs) const { return this->cost > rhs.cost; }
};

struct Graph {
	size_t node;
	std::vector<std::vector<Edge>> edges;

	Graph(size_t n) : node(n), edges(n) {}
};

std::vector<Weight> dijkstra(const Graph& graph, const size_t s) {
	size_t n = graph.node;
	std::vector<bool> used(n, false);
	std::vector<Weight> distances(n, INF);

	distances[s] = 0;
	std::priority_queue<Edge> pq;
	pq.push(Edge(s, 0));
	while(!pq.empty()) {
		Edge edge = pq.top();
		pq.pop();
		if(used[edge.to]) {
			continue;
		}
		used[edge.to] = true;
		for(auto&& e : graph.edges[edge.to]) {
			Weight alt = edge.cost + e.cost;
			if(alt < distances[e.to]) {
				distances[e.to] = alt;
				pq.push(Edge(e.to, alt));
			}
		}
	}

	return distances;
}

// dijkstra ここまで

std::pair<Weight, Graph> prim(const Graph& graph, size_t s) {
	size_t n = graph.node;
	std::vector<bool> used(n, false);
	Weight total = 0;
	Graph mst(n);

	std::priority_queue<Edge> pq;
	pq.push(Edge(-1, s, 0));
	while(!pq.empty()) {
		Edge edge = pq.top();
		pq.pop();
		if(used[edge.to]) {
			continue;
		}
		used[edge.to] = true;
		total += edge.cost;
		if(edge.from != -1) {
			mst.edges[edge.from].push_back(edge);
		}
		for(auto&& e : graph.edges[edge.to]) {
			if(!used[e.to]) {
				pq.push(e);
			}
		}
	}

	return std::pair<Weight, Graph>(total, mst);
}

int main() {
	int v, e;
	scanf("%d %d", &v, &e);
	int s, t, w;
	Graph graph(v);
	REP(i, e) {
		scanf("%d %d %d", &s, &t, &w);
		graph.edges[s].push_back(Edge(s, t, w));
		graph.edges[t].push_back(Edge(t, s, w));
	}

	pair<Weight, Graph> mst = prim(graph, 0);
	printf("%d\n", mst.first);
	return 0;
}


Measured memory_bytes: 14060
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;

	vector<int> line(n);
	foreach(i, line)cin>>i;
	vector<vector<int>> dp(n, vector<int>(2, INF));

	function<int(int, int)> func = [&](int place, int key){
		if(place!=-1&&dp[place][key&1]!=INF)return dp[place][key&1];
		int res = (key&1)?INF-1:-INF+1;
		for(int i=place+1;i<n-1;++i){
			if(key&1){
				chmin(res, func(i, key+1));
			}else{
				chmax(res, func(i, key+1));
			}
		}
		if(key&1){
			int d = (place==-1?a:line[place]);
			chmin(res, abs(line.back()-d));
		}else{
			int d = (place==-1?b:line[place]);
			chmax(res, abs(line.back()-d));
		}
		if(place==-1)return res;
		return dp[place][key&1] = res;
	};

	cout << func(-1, 0) << endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

A.sort()
if A[0] == 0:
    print(0)
    exit()

cnt = 1
for a in A:
    cnt *= a
    if cnt > INF:
        print(-1)
        exit()
print(cnt)


Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
int n,k;
int num[10]={0,1,2,3,4,5,6,7,8,9};

int main(){
    cin>>n>>k;
    int d[k];
    rep(i,k)cin>>d[i];
    sort(d,d+k);
    bool cnt=true;
    for(int i=n;i<10*n;i++){
        int ans=i;
        cnt=true;
        while(ans){
            int r=ans%10;
            ans/=10;
            if(binary_search(d,d+k,r)){cnt=false;break;}
        }
        if(cnt){
        cout<<i<<endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

lis = [a,b,c,d,e]

j = True

for i in range(len(lis)):
  for m in range(len(lis)):
    if abs(lis[i] - lis[m]) > k:
      j = False
    else:
      pass
    
if j:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
X, K, D = map(int, input().split())

if abs(K*D) > abs(X):
    A = X//D
    A %= 2
    if K % 2 == A:
        print(X%D)
    else:
        print(D-X%D)
else:
    print(abs(X)-abs(K*D))

Measured memory_bytes: 9172
N = int(input())
A = [int(a) for a in input().split(" ")]

ans = 0
for i in range(len(A)):
  if i == 0:
    continue
  else:
    if A[i] < A[i - 1]:
      ans += A[i - 1] - A[i]
      A[i] = A[i - 1]

print(ans)

Measured memory_bytes: 32320
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
const int N = 15;
int a[N];
ll ans;
int n,m,book[N][N],x;

int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= m;j++){
			scanf("%d",&book[i][j]);
		}
	}
	ans = inf;
	for(int i = 1;i < (1<<n);i++){
		memset(a,0,sizeof(a));
		int state = i;
		ll tmp = 0;
		for(int j = 0;j < n;j++){
			if((state>>j)&1){
				for(int k = 1;k <= m;k++){
					a[k] += book[j+1][k];
				}
				tmp += book[j+1][0];
			}
		}
		bool f = 1;
		for(int j = 1;j <= m;j++){
			if(a[j] < x) {f = 0;break;}
		}
		if(f) ans = min(ans,tmp);
	}
	if(ans == inf) puts("-1");
	else printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1736
using System;
using System.Linq;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
        string[] line = Console.ReadLine().Split(' ');
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);
        int x = int.Parse(line[2]);

        bool can = false;

        for(int i = a ; i < 10000 ; i += a){
            if(i % b == x){
                can = true;
            }
        }

        if(can){
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
    }                                                                                                                                                                       
}

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

int main(){
	int n;
	string s;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s;
		if(s.substr(0,2) == ">\'"){
			if(s[s.length() - 1] != '~') cout << "NA" << endl;
			else {
				int cnt = 0,pos = 2;
				bool flag = true;
				for(;;pos++){
					if(s[pos] == '#') break;
					if(s[pos] == '=') cnt++;
					else {
						flag = false;
						break;
					}
				}
				if(!flag || !cnt) cout << "NA" << endl;
				else{
					pos++;
					for(int j = 0;j < cnt;j++){
						if(s[pos + j] != '='){
							flag = false;
							break;
						}
					}
					if(s[pos + cnt] != '~') flag = false;
					if(!flag) cout << "NA" << endl;
					else cout << "A" << endl;
				}
			}
		}else if(s.substr(0,2) == ">^"){
			if(s.length() % 2 || s.length() <= 4) cout << "NA" << endl;
			else {
				bool flag = true;
				for(int i = 1;i < s.length() / 2;i++){
					if(i != s.length() / 2 - 1 && s.substr(i * 2,2) != "Q=") flag = false;
					if(i == s.length() / 2 - 1 && s.substr(i * 2,2) != "~~") flag = false;
				}
				if(flag) cout << "B" << endl;
				else cout << "NA" << endl;
			}
		}else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     998244353
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){ return powm(a,m-2,m); }
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a>>b>>c>>d>>k;
p=a*60+b;
q=c*60+d;
x=q-p;
if(x<=k)
{
  ans=0;
}
else
{
  ans=x-k;
}
cout<<ans;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    map<string, int> m;
    for ( int i = 0; i < n; ++i) {
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()



int main(){

    fast;
    int s,i,j;
    cin>>s;
    int dp[s+1];
    mem(dp,0);
    dp[0]=1;
    for(i=3;i<=s;i++)
    {
    	for(j=3;j<=s;j++)
    	{
    		if(i>=j)
    		{
    			dp[i]=(dp[i]+dp[i-j])%mod;
			}
		}
	}
	cout<<dp[s];
    

    

}

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

int main() {
	//freopen("input.txt","r",stdin);
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	c<<=1;
	int mn = min(x,y);
	long long ans = 0;
	if(c < a + b)ans = c*mn,x-=mn,y-=mn;
	if(x)ans+=min(c,a)*x;
	if(y)ans+=min(c,b)*y;
	cout << ans << endl;
}

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

typedef long long ll;

ll aux1(vector<ll> &b, ll i){
  return (b.size()>i&&i>=0)?b[i]:0;
}

int main(){
  ll n,k; cin>>n>>k;
  string s; cin>>s;
  vector<ll> blob0, blob1;
  
  char c_first=s[0];
  
  char c_pre='x';
  ll cnt=0;
  for(ll i=0;i<n;i++){
    char c = s[i];
    if(c!=c_pre){
      if(c=='0') blob0.push_back(1);
      if(c=='1') blob1.push_back(1);
    } else {
      if(c=='0') blob0.back()++;
      if(c=='1') blob1.back()++;
    }
    c_pre = c;
  }
  
  
  ll dp[100001];
  for(ll i=0;i<100001;i++){
    dp[i]=0;
  }
  
  if(c_first=='0'){
    for(ll i=0;i<k;i++){
      dp[0]+=aux1(blob0,i)+aux1(blob1,i);
    }
    for(ll i=1;i<blob0.size();i++){
      dp[i]=dp[i-1]-blob0[i-1]+aux1(blob0,i+k-1)-aux1(blob1,i-2)+aux1(blob1,i+k-1);
    }
  } else {
    dp[0]=blob1[0];
    for(ll i=0;i<k;i++){
      dp[0]+=aux1(blob0,i)+aux1(blob1,i+1);
    }
    for(ll i=1;i<blob0.size();i++){
      dp[i]=dp[i-1]-blob0[i-1]+aux1(blob0,i+k-1)-aux1(blob1,i-1)+aux1(blob1,i+k);
    }
  }
  
  ll ans=0;
  for(ll i=0;i<100001;i++){
    if(ans<dp[i]) ans=dp[i];
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 2164
// D - Friend Suggestions
// UnionFinde version (with rank)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (rank)
	vector<int> parent;//parent number
	vector<int> rank;//rank
	vector<int> g_size;//group size
	public:
	UnionFind(int n){
		parent.resize(n);
		rank.resize(n);
		g_size.resize(n);
		for(int v=0; v<parent.size(); ++v){
			parent[v] = v;
			rank[v] = 0;
			g_size[v] = 1;
		}
	}
	int root(int v){//get root
		if(parent[v]==v) return v;//root
		return parent[v] = root(parent[v]);//path compression
	}
	void unite(int v, int u){
		v = root(v); u = root(u);
		if(v==u) return;
		//concat low rank to high rank (but rank is no compress)
		if(rank[v]<rank[u]){
			g_size[u] += g_size[v];
			g_size[v] = 0;
			parent[v] = u;
		}
		else{
			g_size[v] += g_size[u];
			g_size[u] = 0;
			parent[u] = v;
			if(rank[v]==rank[u]) rank[v]++;//fix rank when same rank concat
		}
	}
	bool same(int v, int u){return root(v)==root(u);}//v & u the same set
	int size(int v){
		return g_size[root(v)];
	}
};

int main(){
	int N,M,K; cin>>N>>M>>K;
	UnionFind uf(N);
	vi C(N);
	int s,t;
	rp(i,0,M){
		cin>>s>>t; s--; t--;
		uf.unite(s,t);
		C[s]++; C[t]++;
	}
	rp(i,0,K){
		cin>>s>>t; s--; t--;
		if(uf.same(s,t)) C[s]++, C[t]++;
	}
	rp(i,0,N) cout<< uf.size(i)-C[i]-1 <<" ";
}

Measured memory_bytes: 2432
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int maxWeight = scn.nextInt();
		int[][] itemvaw = new int[n+1][2];
		
		for(int i=1;i<=n;i++){
		    itemvaw[i][0] = scn.nextInt();
		    itemvaw[i][1] = scn.nextInt();
		}
		long[][] memo = new long[n+1][maxWeight+1];
		System.out.println(knapsack_memoized(1,itemvaw,maxWeight,memo));
	}
	
	public static long knapsack_memoized(int cii, int[][] itemvaw, int capacityLeft, long[][] memo) {
		if (cii == itemvaw.length)return 0;
		if (capacityLeft == 0)return 0;
		if (memo[cii][capacityLeft] != 0)return memo[cii][capacityLeft];
		long o1 = capacityLeft - itemvaw[cii][0] >= 0 ?
		         itemvaw[cii][1] + knapsack_memoized(cii + 1, itemvaw, capacityLeft - itemvaw[cii][0], memo) : Integer.MIN_VALUE;
		long o2 = knapsack_memoized(cii + 1, itemvaw, capacityLeft, memo);
		return memo[cii][capacityLeft] = Math.max(o1, o2);
	}
}


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

/*typedefs*/
typedef vector<int> vi;
typedef map<string,int> msi;
typedef complex<double> point;
typedef  long long ll;


#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}


unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
ll  OO = 10e12;
int x;

int main() {
    int A,H;
    scanf("%d %d",&H,&A);
    printf("%d\n",(H/A) +!!(H%A));

    return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    s = input()
    q = int(input())

    is_true = True

    d = deque(s)

    for _ in range(q):
        input_list = list(input().split())
        if input_list[0] == '1':
            if is_true:
                is_true = False
            else:
                is_true = True
            continue
        if input_list[1] == '1':
            if is_true:
                d.appendleft(input_list[2])
            else:
                d.append(input_list[2])

        else:
            if is_true:
                d.append(input_list[2])
            else:
                d.appendleft(input_list[2])
            
    if not is_true:
        d.reverse()

    print(''.join(d))

if __name__ == '__main__':
    main()


Measured memory_bytes: 80216
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;
const int N = 1e4;
set<int> way;
vector<int> gr[N], fway;
map<pii, pii> w;
int used[N], n;
ll totaltime = 0, totalamount = 0;
void dfs(int v)
{
    if(v == n)
    {
        for(auto e : way)fway.pb(e);
        return;
    }
    used[v] = 1;
    for(auto e : gr[v])
    {
        if(!used[e])
        {
            way.insert(e);
            dfs(e);
            way.erase(e);
        }
    }
}
int main()
{
    fast;
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    FOR(i, n / 2, 0)
    {
        if(s[i] != s[n - i - 1])ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d %d %d",$a,$b,$c);

$ans="";
if($a<>$b){
	if($a<$b){
		if($c>$a && $b>$c){
			$ans="Yes";
		}
	}else{
		if($a>$c && $c>$b){
			$ans="Yes";
		}
	}
}

if($ans==""){
	$ans="No";
}

echo $ans;
?>

Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class RollingHash(object):
    __base1=1007; __mod1=10**9+9
    __base2=1009; __mod2=10**9+7

    def __init__(self,s):
        self.__s=s; self.__n=len(s)
        b1=self.__base1; m1=self.__mod1
        b2=self.__base2; m2=self.__mod2
        H1,H2=[0]*(self.__n+1),[0]*(self.__n+1)
        P1,P2=[1]*(self.__n+1),[1]*(self.__n+1)
        for i in range(self.__n):
            H1[i+1]=(H1[i]*b1+ord(s[i]))%m1
            H2[i+1]=(H2[i]*b2+ord(s[i]))%m2
            P1[i+1]=P1[i]*b1%m1
            P2[i+1]=P2[i]*b2%m2
        self.__H1=H1; self.__H2=H2
        self.__P1=P1; self.__P2=P2

    def __getitem__(self,x):
        if(isinstance(x,int)): x=slice(x,x+1)
        assert(isinstance(x,slice) and ((x.step is None) or (x.step==1)))
        l=x.start; r=x.stop;
        assert(l<=r)
        return ((self.__H1[r]-self.__P1[r-l]*self.__H1[l]%self.__mod1)%self.__mod1,
                (self.__H2[r]-self.__P2[r-l]*self.__H2[l]%self.__mod2)%self.__mod2)

def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

def resolve():
    n=int(input())
    S=input()
    rh=RollingHash(S)

    from collections import defaultdict
    def check(k):
        D=defaultdict(lambda :-1)
        for i in range(n-k+1):
            hash=rh[i:i+k]
            if(D[hash]!=-1):
                if(i-D[hash]>=k): return True
            else:
                D[hash]=i
        return False

    print(bisection(0,n,check))
resolve()

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

int main() {
    string s[3];
    string ans = "";
    
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    
    for (int i = 0; i < 3; i++) {
        ans += s[i][i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

import sys
N = int(input())
count = 0
if N == 1:
    print(count)
    sys.exit()

for i in factorization(N):
    a = 1
    while i[1] >= a*(a+1)/2:
        a += 1
        count += 1
        
print(count)

Measured memory_bytes: 9492
// 2012/11/07 Tazoe

#include <iostream>
using namespace std;

int gcd(int a, int b)
{
	if(b==0)
		return a;

	return gcd(b, a%b);
}

int main()
{
	while(true){
		int a, b;
		cin >> a >> b;

		if(cin.eof())
			break;

		int g = gcd(a, b);
		cout << g << ' ' << a/g*b << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q;
ll A[200001];
ll B[200001];
ll D[200001];
ll T[200001];
ll ans;
string S;
ll K;
map<ll, ll> m;
char ansmap[102][102];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	cin >> N;
	cin >> K;
	if (K == 0) {
		cout << N * N << endl;
		return 0;
	}
	rep(i, K+1, N+1) {
		ans += (i - K)*(N / i);
		if (N%i != 0) {
			ll num = i * ((N + i - 1) / i);
			num -= i - K;
			if (N >= num) {
				ans += N - num + 1;
			}
		}

	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	ll sum = 0;
	map<ll, ll> nums;
	++nums[0];
 
	rep(i, n) {
		cin >> a[i];
	}
	for (ll i = 0; i < n; ++i) {
		sum += a[i];
		++nums[sum];
	}
	for (auto it = nums.begin(); it != nums.end(); ++it) {
    	ans += it->second * (it->second - 1) / 2;
  	}
	cout << ans << endl;
}

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

int main() {
  string n;
  cin >> n;
  int c = 0;
  for(int i = 1;i <= 2;i++)
    (n[i] == n[i-1] && n[i] == n[i+1])?
      c++:
      0;
  (c != 0)?
    cout << "Yes" << endl:
    cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
n = (N//2) - 1
X = list(map(int,input().split()))
import copy
Y = copy.deepcopy(X)
Y.sort()
a = Y[n]
b = Y[n+1]
for i in range(N):
    ans = a
    if X[i] <= a:
        ans = b
    print(ans)


Measured memory_bytes: 26772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> dic(100010,0);
    for(int i=0; i<n; i++){
        int a,b; cin>>a>>b;
        dic[a] += b;
    }
    ll i=0, acu=0;
    while(acu < k){
        acu += dic[i];
        i++;
    }
    OUT(i-1);
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define mod 998244353
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int bin[2][500010],fac[500010],inv[500010];
inline int C(int m,int n){return 1LL*fac[m]*inv[n]%mod*inv[m-n]%mod;}
inline int A(int m,int n){return 1LL*fac[m]*inv[m-n]%mod;}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    if(n>m)swap(n,m);
    bin[0][0]=1;for(int i=1;i<=n;i++)bin[0][i]=1LL*bin[0][i-1]*(m+1)%mod;
    bin[1][0]=1;for(int i=1;i<=m;i++)bin[1][i]=1LL*bin[1][i-1]*(n+1)%mod;
    fac[0]=1;for(int i=1;i<=m;i++)fac[i]=1LL*fac[i-1]*i%mod;
    inv[m]=power(fac[m],mod-2);
    for(int i=m;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    int ans=1LL*bin[0][n]*bin[1][m]%mod;
    for(int i=1;i<=n;i++)
    {
    	int uf=1LL*C(n,i)*A(m,i)%mod*bin[0][n-i]%mod*bin[1][m-i]%mod;
    	if(i&1)ans=(ans-uf+mod)%mod;
    	else ans=(ans+uf)%mod;
    }pr2(ans);
    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
    using namespace std;
    #define MOD 1000000007
    #define PI 3.14159265358979323846264
    #define pii pair <int, int>
    #define pipii pair <int, pair <int, int> > 
    #define piipi pair <pair <int, int>, int>
    #define pb push_back
    #define mp make_pair
    #define vi vector <int>
    #define vl vector <long long>
    #define vpii vector <pair <int, int> >
    #define ll long long
    #define fi first
    #define se second
    #define FOR(i, x, y) for (int i=x; i<=y; i++)
    #define FORD(i, y, x) for (int i=y; i>=x; i--)
    #define debug printf("OK\n")
    int n, a[100005];
    int main() {
        cin >> n;
        for (int i=1; i<=n; i++) cin >> a[i];
        for (int i=n; i>1; i--) {
            if (a[i] < a[i-1]) a[i-1]--;
        }
        for (int i=2; i<=n; i++) {
            if (a[i] < a[i-1]) {
                printf("No\n");
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  long N;
  cin >> N;
  
  long ans = LONG_MAX;
  for (long a = 1; a <= pow(N,0.5); a++) {
    
    if(N%a!=0) continue;
    long b = N/a;
    ans = min(ans, a+b-2);
  }

  cout << ans << endl;
  return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	int x, y, a, b, c;	cin >> x >> y >> a >> b >> c;
	long long int p[a];
	for( int i = 0; i < a; i++ ){
		cin >> p[i];
	}
	long long int q[b];
	for( int i = 0; i < b; i++ ){
		cin >> q[i];
	}
	long long int r[c];
	for( int i = 0; i < c; i++ ){
		cin >> r[i];
	}
	vector<long long int> eat;
	long long int ans = 0;
	int cur = 0;

	sort( p, p + a, greater<long long int>() );
	sort( q, q + b, greater<long long int>() );
	sort( r, r + c, greater<long long int>() );

	for( int i = 0; i < x; i++ ){
		eat.push_back( p[i] );
	}
	for( int i = 0; i < y; i++ ){
		eat.push_back( q[i] );
	}
	sort( all(eat) );

	for( int i = 0; i < x + y; i++ ){
		if( eat[i] < r[cur] && cur < c ){
			eat[i] = r[cur];
			cur++;
		}
	}

	for( int i = 0; i < x + y; i++ ){
		ans += eat[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7676