akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int, long[]> read = i => new int[i].Select(_ => long.Parse(Console.ReadLine())).ToArray();
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var s = read(h[0]);
		var t = read(h[1]);
		var x = read(h[2]);

		var st = Map(s, t);
		var ts = Map(t, s);
		Console.WriteLine(string.Join("\n", x.Select(p => Math.Min(Find(p, s, st), Find(p, t, ts)))));
	}

	static long[] Map(long[] u, long[] v)
	{
		var uv = new long[u.Length];
		for (int i = 0, j = 0; i < u.Length; i++)
		{
			while (j < v.Length && v[j] < u[i]) j++;
			uv[i] = Math.Min(j == 0 ? long.MaxValue : u[i] - v[j - 1], j == v.Length ? long.MaxValue : v[j] - u[i]);
		}
		return uv;
	}

	static long Find(long p, long[] u, long[] uv)
	{
		var i = ~Array.BinarySearch(u, p);
		return Math.Min(i == 0 ? long.MaxValue : p - u[i - 1] + uv[i - 1], i == u.Length ? long.MaxValue : u[i] - p + uv[i]);
	}
}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,n,m,array[100000+10],ans=0,sum1=0,sum2=0,sum3=0,sum=0,cnt=0,cnt1=0,cnt2=0,cnt3=0,flag=0,flag1,flag2;
    int i,j;
    string s[100],p;
    char ch;
    cin>>m>>n;
    if(m==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


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

using namespace std;

template<typename T>
struct node {
    T value;
    node<T>* left;
    node<T>* right;
    
    node(T v) : value(v), left(NULL), right(NULL) {}
    ~node() {
        if(left!=NULL) delete left;
        if(right!=NULL) delete right;
    }   
    
    template<class Func>
    void preorder(Func f) {
        f(value);
        if(left!=NULL) left->preorder(f);
        if(right!=NULL) right->preorder(f);
    }
    
    template<class Func>
    void inorder(Func f) {
        if(left!=NULL) left->inorder(f);
        f(value);
        if(right!=NULL) right->inorder(f);
    }
};

template<typename T>
struct BST {
    node<T>* root;
    
    BST() : root(NULL) {}
    ~BST() {
        if(root!=NULL) delete root;
    }
    
    void insert(T v) {
        node<T>** insertp = &(root);
        node<T>* cur = root;
        while(cur != NULL) {
            if(v < cur->value) {
                insertp = &(cur->left);
                cur = cur->left;
            } else {
                insertp = &(cur->right);
                cur = cur -> right;
            }
        }
        *insertp = new node<T>(v);
    }
    
    bool find(T v) {
        node<T>* cur = root;
        while(cur != NULL) {
            if(v == cur->value) return true;
            if(v < cur->value) cur = cur->left;
            else cur = cur->right;
        }
        return false;
    }
    
    template<class Func>
    void inorder(Func f) {
        if(root!=NULL) root->inorder(f);
    }
    
    template<class Func>
    void preorder(Func f) {
        if(root!=NULL) root->preorder(f);
    }
};

int main() {
    int n;
    cin >> n;
    BST<int>* bst = new BST<int>();
    for(int i=0; i<n; i++) {
        string cmd;
        cin >> cmd;
        if(cmd=="insert") {
            int v;
            cin >> v;
            bst->insert(v);
        } else if(cmd=="print") {
            bst->inorder([](int v){cout << " " << v;});
            cout << endl;
            bst->preorder([](int v){cout << " " << v;});
            cout << endl;
        } else if(cmd=="find") {
            int v;
            cin >> v;
            cout << (bst->find(v) ? "yes" : "no") << endl;
        }
    }
    delete bst;
}


Measured memory_bytes: 15684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());

			if (n == 0)
				break;

			ArrayList<String> str = new ArrayList<>();

			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				str.add(s);
			}

			int wordSum = 0;
			int goro[] = { 5, 7, 5, 7, 7 };
			int goroI = 0;
			boolean flag = false;
			int ans = 0;

			for (int i = 0; i < n; i++) {
				for (int j = i; j < n; j++) {
					wordSum += str.get(j).length();
					if (goro[goroI] < wordSum) {
						goroI = 0;
						wordSum = 0;
						break;
					}
					if (goro[goroI] == wordSum) {
						goroI++;
						wordSum = 0;
						if (goroI == 5) {
							flag = true;
							ans = i + 1;
							break;
						}
					}
				}
				if (flag)
					break;
			}
			System.out.println(ans);
		}
	}

}


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

int main() {
  int n, x, count;
  while (true) {
    cin >> n >> x;
    count = 0;
    if (!(n || x)) break;

    for (int a = 1; a <= n - 2; a++) {
      for (int b = a + 1; b <= n - 1; b++) {
        for (int c = b + 1; c <= n; c++) {
          if ((a + b + c) == x) count++;
        }
      }
    }
    cout << count << endl;
  }
}



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


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	    
	    if(nums[0] == 1) nums[0] = 14;
        if(nums[1] == 1) nums[1] = 14;
	
	    if(nums[0] > nums[1])
	    {
	        Console.WriteLine("Alice");
	    }
	    else if(nums[1] > nums[0])
	    {
	        Console.WriteLine("Bob");
	    }
	    else
	    {
	        Console.WriteLine("Draw");
	    }
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>

using namespace std;

const int mod=1e9+7; 

int main()
{
//	freopen("input.txt","r",stdin);//设置 cin scanf 这些输入流都从 test.in中读取
    
    int x;
	cin>>x;
	if(x>=30) cout<<"Yes";
	else cout<<"No"; 
    
	return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

class Program{
    static void Main(){
        long n = long.Parse(Console.ReadLine());
        long ans = 0;
        for (long k = 1;;k++){
            if (n <= k * (k + 1)) break;
            if (n % k != 0) continue;
            ans += n / k - 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#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
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;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  void operator++() {
      x += 1;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  void operator--() {
      x -= 1;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int n,bl;
    cin >> n >> bl;
    int re = n-bl;
    vector<mint> ans(bl+1);
    combination c(10000);
    rep2(i,1,bl+1) {
        if(re < i-1) break;
        mint nans = 1;
        nans *= c(bl-1,bl-i);
        nans *= c(re+1,re-i+1);
        ans[i] = nans;
    }
    rep2(i,1,bl+1) cout << ans[i].x << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=true;

/*---------------------------------------------------*/

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  ll cnt=1;
  if(k==0){
    cout<<n*n<<endl;
    return 0;
  }
  for(int i=k+1;i<=n;i++){
    //cout<<i<<" -> "<<((n-i+1)/i*cnt+cnt)<<" "<<max(0,(n-i+1)%i-k)<<" "<<cnt<<endl;
    ans+=((n-i+1)/i*cnt+cnt)+max(ll(0),(n-i+1)%i-k);
    cnt++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

# a, bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

# a, bの最小公倍数
def lcm(a, b):
    return int(a * b) // gcd(a,b)

# リストnumbers最小公倍数
def lcmlist(numbers):
    a = numbers[0]
    for i in range(1, len(numbers)):
        a = lcm(a, numbers[i])
    return int(a)

#### START
n = int(input())
t = [int(input()) for i in range(n)]

print(lcmlist(t))


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

int main(){
    int H, W, i, j;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        i = 0;
        while(i < W){
            cout << "#";
            i++;
        }
        cout << endl;
        j = 0;
        while(j < H-2){
            cout << "#";
            i = 0;
            while(i < W-2){
                cout << ".";
                i++;
            }
            cout << "#" << endl;
            j++;
        }
        i = 0;
        while(i < W){
            cout << "#";
            i++;
        }
        cout << endl;
        cout << endl;
    }
    return 0;
}


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


int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int sum=0;
  int total=0;
  for(int num=1;num<=N;num++){
    int n=num;
    sum=0;
    while(n>0){
      sum+=n%10;
      n/=10;
    }
    if(A<=sum&&sum<=B){
      total+=num;
    }
  }
  cout << total<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N, M;
        public int[] P;


        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
                P = Input.ReadIntArray();
                for (int i = 0; i < N; i++) P[i]--;
            }

            var U = new UnionFind(N);
            for (int i = 0; i < M; i++)
            {
                var line = Input.ReadIntArray();
                int a = line[0] - 1;
                int b = line[1] - 1;
                U.Unite(a, b);
            }

            var dic = new Dictionary<int, List<int>>();
            for (int i = 0; i < N; i++)
            {
                int p = U.Find(i);
                if(!dic.ContainsKey(p)) dic.Add(p, new List<int>());
                dic[p].Add(i);
            }

            int ret = 0;
            foreach (var k in dic.Keys)
            {
                var vs = dic[k];
                var xs = vs.Select(i => P[i]).ToList();
                ret += vs.Intersect(xs).Count();
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    class UnionFind
    {
        public List<int> Par;
        public List<int> Sizes;

        public UnionFind(int n)
        {
            Par = new List<int>();
            Sizes = new List<int>();
            for (int i = 0; i < n; i++)
            {
                Par.Add(i);
                Sizes.Add(1);
            }
        }

        public int Find(int x)
        {
            if (x == Par[x]) return x;
            Par[x] = Find(Par[x]);
            return Par[x];
        }

        public void Unite(int x, int y)
        {
            x = Find(x);
            y = Find(y);
            if (x == y) return;

            if (Sizes[x] < Sizes[y])
            {
                // swap
                int temp = x;
                x = y;
                y = temp;
            }

            Par[y] = x;
            Sizes[x] += Sizes[y];
            Sizes[y] = 0;
        }

        public bool Same(int x, int y)
        {
            return Find(x) == Find(y);
        }

        public int Size(int x)
        {
            return Sizes[Find(x)];
        }
    }

    // common ----------

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 38980
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int a[3][3], flg[3][3];
	rep(i,3){
		rep(j,3){
			cin >> a[i][j];
			flg[i][j] = 0;
		}
	}

	int n; cin>>n;
	rep(k,n){
		int b; cin>>b;
		rep(i,3){
			rep(j,3){
				if(a[i][j]==b){
					flg[i][j] = 1;
					cerr<< i SP j <<endl;
				}
			}
		}
	}
	// rep(i,3){
	// 	rep(j,3) cerr<<a[i][j] << ' ';
	// 	cerr << endl;
	// }
	// rep(i,3){
	// 	rep(j,3){
	// 		cerr << flg[i][j] << ' ';
	// 	}
	// 	cerr << endl;
	// }

	string ans = "No";
	rep(i,3){
		if(flg[i][0]&&flg[i][1]&&flg[i][2]) ans = "Yes", cerr<<i<<endl;
		if(flg[0][i]&&flg[1][i]&&flg[2][i]) ans = "Yes", cerr<<i<<endl;
	}
	if(flg[0][0]&&flg[1][1]&&flg[2][2]) ans = "Yes", cerr<<4<<endl;
	if(flg[2][0]&&flg[1][1]&&flg[0][2]) ans = "Yes", cerr<<4<<endl;

	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
function main()
    N, M = [parse(Int, s) for s in split.(readline())]
    edges = [Int[] for _ in 1:N]
  	for i in 1:M
        a, b = [parse(Int, s) for s in split.(readline())]
        push!(edges[a], b)
        push!(edges[b], a)
    end
#    for i in 1:N
#        edges[i] = sort(collect(Set(edges[i])))
#    end

    quedata = zeros(Int, N+M+10000)
    quedata[1] = 1
    ques, quee = 1, 2

    visited = falses(N)
    to_room = zeros(Int, N)

    while ques != quee
        pos = quedata[ques]
        ques += 1
        ques > length(quedata) && (ques = 1)
        visited[pos] && continue
        visited[pos] = true
        for topos in edges[pos]
            iszero(to_room[topos]) && (to_room[topos] = pos)
            if !visited[topos]
                quedata[quee] = topos
                quee += 1
                quee > length(quedata) && (quee = 1)
            end
        end
    end
    if !all(visited)
        println("No")
        return
    end

    println("Yes")
    for i in 2:N
        println(to_room[i])
    end
end

main()


Measured memory_bytes: 236156
/*
 * atcoder/abc138/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 200000;
int N, Q;
vector<int> G[MAX];
vector<ll> X(MAX, 0);
vector<ll> Y(MAX, 0);

void dfs(int n = 0, int prev = -1, ll score = 0) {
  score += X[n];
  Y[n] = score;
  for (auto&& v: G[n]) {
    if (v == prev) continue;
    dfs(v, n, score);
  }
}

void solve() {
  cin >> N >> Q;
  int a, b, p, x;
  loop(n,0,N-1) {
    cin >> a >> b; a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  loop(q,0,Q) {
    cin >> p >> x;
    p--;
    X[p] += x;
  }
  dfs();
  loop(n,0,N) cout << Y[n] << " ";
  cout << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=305;
//i_am_noob
int ans=0;
string str1,str2;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> str1 >> str2;
    rep(sz(str1)) if(str1[i]!=str2[i]) ans++;
    print1(ans);
    return 0;
}


Measured memory_bytes: 3664
def gcd(a,b):
  if a<b:
    a,b = b,a
  while b!=0:
    a,b=b,a%b
  return a
   
def lcm(a,b):
  return a*b//gcd(a,b)

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

cnum = B // C - (A-1) // C
dnum = B // D - (A-1) // D
xnum = B // lcm(C,D) - (A-1) // lcm(C,D)

#print(cnum, dnum, xnum)
print(B - A + 1 - (cnum + dnum - xnum))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

const int MOD = 2019;

int main(){
    ios;
    string S; cin >> S;
    unordered_map<int,int>Remainders;
    Remainders[0] = 1;
    int _10Power = 1, number = 0, remainder;
    for(ll i = S.size() - 1; ~i; --i){
        number += (S[i] - '0') * _10Power;
        remainder = number % MOD;
        ++Remainders[remainder];
        _10Power *= 10;
        _10Power %= MOD;
        number   %= MOD;
    }
    ll ans = 0;
    for(auto rem : Remainders){
        ans += (rem.second * (rem.second - 1)) / 2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <iostream>
#include <sstream>
using namespace std;

int main() {
  string N;
  getline(cin, N);
  istringstream s(N);

  int a, b;
  s >> a >> b;

  //差分
  int c = b - a;

  // cout << c << endl;

  // a は、c-1番目の塔
  //aの高さを求める
  int d = 1;

  for (int i = 2; i < c ; i++)
  {
    d += i;
  }
  
  // cout << d << endl;

  int x = d - a;

  cout << x << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin>>s;
	bool ok=false;
	lol(i,s.size()){
		for(int j=i+1;j<s.size();j++){
			if(s[i]=='C'&&s[j]=='F')ok=true;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int a, b;
    cin >> a >> b;
    if(a < b) {
        rep(i, b) {
            cout << a;
        }
    } else {
        rep(i, a) {
            cout << b;
        }
    }
    cout << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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

  int ab_max = max(a, b);
  vector<int> v;
  for (int i = 1; i <= ab_max; i++) {
    if (a % i == 0 && b % i == 0) {
      v.push_back(i);
    }
  }

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

  cout << v.at(k-1) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	int l[n];
	for(int i=0;i<n;i++)
		cin >> l[i];
	sort(l,l+n);
	int sum=0;
	for(int i=0;i<k;i++)
		sum+=l[n-1-i];
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<int> ans(n);
    vector<bool> b(n);
    for (int i = 0; i < m; ++i)
    {
        int s, c;
        cin >> s >> c;
        if (b.at(s-1) && ans.at(s-1) != c ) {
            cout << -1 << endl;
            return 0;
        }
        ans.at(s-1) = c;
        b.at(s-1) = true;
    }

    for (int i = 0; i <n; ++i) {
        if (ans.at(i) != 0) break;
        if (ans.at(i) == 0 && b.at(i) && i != n-1) {
            cout <<-1 << endl;
            return 0;
        }
    }
    if(ans.at(0) == 0 && n != 1) ans.at(0) = 1;

    for (int i = 0; i < n; ++i) cout << ans.at(i);
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int Q;long long x,y,z;
int main()
{
	scanf("%d",&Q);
	while(Q--)
	{
		scanf("%lld%lld",&x,&y);
		if(x>y)swap(x,y);
		z=int(sqrt(x*y));
		if(z*(z+1)<x*y)
			printf("%lld\n",2*z-1);
		else
		{
			if(z*z==x*y)
			{
				if(x==y)
					printf("%lld\n",2*z-2);
				else
					printf("%lld\n",2*z-3);
			}
			else
				printf("%lld\n",2*z-2);
		}
	}
	return 0;
}


Measured memory_bytes: 128
s = list(input())

h = {}
for c in s:
  if c not in h:
    h[c] = 0
  h[c] += 1

count_eq_2 = True
for c in h:
  if h[c] != 2:
    count_eq_2 = False
    
if len(h) == 2 and count_eq_2:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

Measured memory_bytes: 3060
h, w, a, b = gets.split.map(&:to_i)
1.upto(h) do |i|
    1.upto(w) do |j|
        if i <= b then
            if j <= a then
                print '1'
            else
                print '0'
            end
        else
            if j <= a then
                print '0'
            else
                print '1'
            end
        end
    end
    print "\n"
end


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

int main()
{
    int n;
    cin >> n;
    int d[100002];
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n;
  scanf("%d", &n);
  int r = n;
  while(r%2 != 0 || r%n != 0) {
    r += n;
  }
  printf("%d\n", r);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String k = "keyence";
        String s = sc.next();
        int len = k.length();
        boolean bool = false;
        for(int i = 0; i < len; i++){
            String k1 = k.substring(0,i);
            String k2 = k.substring(i,len);
            int a1 = s.indexOf(k1);
            int a2 = s.lastIndexOf(k2);
            int chk = check(k,s,k1,k2,a1,a2);
            if(a1 != -1 && a2 != -1 && chk >= 2){
                bool = true;
                break;
            }
        }
        System.out.println(bool ? "YES" : "NO");
    }
    
    private static int check(String k, String s, String k1, String k2, int a1, int a2){
        int ret = 0;
        if(a1 == 0) ret++;
        if(a2 + k2.length() == s.length()) ret++;
        if(a1 + k1.length() == a2) ret++;
        return ret;
    }
}


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

using namespace std;

int main()
{
	int N;
	int x[100000];
	int y[100000];
	int t[100000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	int nx = 0, ny = 0, nt = 0;
	for (int i = 0; i < N; i++) {
		int dx = abs(nx - x[i]);
		int dy = abs(ny - y[i]);
		int dt = abs(nt - t[i]);
		int t = dt - dx - dy;
		if (t < 0 || t % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String str = br.readLine();
			String[] strArr = str.split(" ");

			// ??\?????¶??°???????????¨????????\???
			int n = Integer.parseInt(strArr[0]);
			int m = Integer.parseInt(strArr[1]);

			// ?¨??????¨??????
			String[][] a = new String[n][m];
			String[] b = new String[m];

			// n ?? m ?????? ?????\???
			for(int i=0;i<n;i++){
				str = br.readLine();
				a[i] = str.split(" ");

			}
			// n ?? 1 ?????? ?????\???
			for(int i=0;i<m;i++){
				b[i] = br.readLine();
			}

			// ?¨???? ??????
			int sum;
			for(int i=0;i<n;i++){
				sum=0;
				for(int j=0;j<m;j++){
					sum+=Integer.parseInt(a[i][j]) * Integer.parseInt(b[j]);
				}
				System.out.println(sum);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try{
				if(br != null){
					br.close();
				}
			}catch(IOException ioe){
			}

		}
	}
}

Measured memory_bytes: 24308
#include<stdio.h>
int A[12];
int main()
{
int i,a,b,c=0,d=0,n,e=0,f=0,l=-1,j;
char S[102];
	scanf("%d",&n);
while(n!=0){
	for(i=0;i<10;i++){
	A[i]=0;
	}
	scanf("%s",&S);
	for(i=0;i<100;i++){
	l++;
	if(l==n){
	l=0;
	}
	if(S[i]=='M'){
	A[l]++;
	}
	else if(S[i]=='S') {
	f=f+A[l]+1;
	A[l]=0;
	}
	else if(S[i]=='L'){
	A[l]=A[l]+(f+1);
	f=0;
	}
	}
	l=-1;
	for(i=0;i<n;i++){
		for(j=n-1;j>=i;j--){
		if(A[i]>A[j]){
		c=A[i];
		A[i]=A[j];
		A[j]=c;
		}
		
		}
	}
	for(i=0;i<n;i++){
	printf("%d ",A[i]);
	}
	printf("%d\n",f);
	f=0;
	scanf("%d",&n);
	}
	return 0;
	
}

Measured memory_bytes: 1032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]%=2;
  }

  ll ans=0;
  for(int i=0;i<n;i++){
    if(a[i]) ans++;
  }
  if(ans%2) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
M = list(map(int, input().split()))
H = list(map(int, input().split()))

sum_m = 0
rest = 0
for i in range(N):
  if M[i] >= H[i]+rest:
    sum_m += H[i]+rest
    rest = 0
  else:
    sum_m += M[i]
    rest = min(H[i], H[i]+rest-M[i])
sum_m += min(rest, M[-1])

print(sum_m)


Measured memory_bytes: 18476
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<u64>();
    let mut i = 1;
    let mut ans = 0;
    if n == 1 {
        println!("0");
        return;
    }

    while i * i <= n {
        let cand = n / i - 1;
        if n % cand == n / cand {
            ans += cand;
        }
        i += 1;
    }
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int cnts[109];

void factors(int k) {
    int p = 2;
    while (k > 1) {
        if (k % p == 0) {
            cnts[p]++;
            k /= p;
        } else {
            p++;
        }
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    FOR(i, 2, N) {
        factors(i);
    }
    ll ans = 0;
    FOR(i, 2, N) if (cnts[i] > 73) ans++; 
    FOR(i, 2, N) {
        FOR(j, i + 1, N) {
            if (cnts[i] > 23 && cnts[j] > 1) ans++;
            if (cnts[j] > 23 && cnts[i] > 1) ans++;
            if (cnts[i] > 13 && cnts[j] > 3) ans++;
            if (cnts[j] > 13 && cnts[i] > 3) ans++;
        }
    }
    FOR(i, 2, N) {
        FOR(j, i + 1, N) {
            FOR(k, j + 1, N) {
                if (cnts[i] > 3 && cnts[j] > 3 && cnts[k] > 1) ans++;
                if (cnts[i] > 1 && cnts[j] > 3 && cnts[k] > 3) ans++;
                if (cnts[i] > 3 && cnts[j] > 1 && cnts[k] > 3) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const long long MOD=1e9+7;

int main(){
    long long N,K;
    cin>>N>>K;
    long long ans=0;
    for(long long i=K;i<=N+1;++i){
        long long m=i*(i-1)/2;
        long long M=i*(2*N-i+1)/2;
        ans+=M-m+1;
        ans%=MOD;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<vector<int>> cnt(10,vector<int>(10,0));
    rep2(i,1,N+1){
        int a=i;
        while(a>9) a/=10;
        ++cnt[a][i%10];
    }
    int ans=0;
    rep(i,10) rep(j,10){
        ans+=cnt[i][j]*cnt[j][i];
    }
    cout << ans << endl;
}

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

int main(){
while(true){
        int n,m,takai;
        cin>>n>>m;
        if(n==0&&m==0){
                break;
        }
        takai=0;
        int a[n];
        for(int i=0;i<n;i++){
                cin>>a[i];
        }
        for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                        if(i!=j){
                                if((a[i]+a[j]<=m)&&(a[i]+a[j]>takai)){
                                        takai=a[i]+a[j];
                                }
                        }
                }
        }
        if(takai!=0){
        cout<<takai<<endl;
        }
        else{
        cout<<"NONE"<<endl;
        }
}
return 0;
}

 
 

Measured memory_bytes: 3000
#include<stdio.h>

int main(void)
{
  int n,ans=0,i;
  char s[60];
  scanf("%d%s",&n,s);
  for(i=0;s[i]!='\0';i++)
    if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
        ans++;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;

int main(){
    typedef pair<int,int> pair;
    int H,W;
    cin>>H>>W;
    char S[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cin>>S[i][j];
    }
    int x[]={1,0,-1,0},y[]={0,1,0,-1};
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int n=0;
            if (S[i][j]=='.'){
                queue<pair> que;
                que.push(pair(i,j));
                vector<vector<int> > v(H,vector<int>(W,-1)); 
                v[i][j]=0;
                while(!que.empty()){
                    pair q=que.front();
                    que.pop();
                    for (int k=0;k<4;k++){
                        int a=q.first,b=q.second;
                        if (a+x[k]<H && a+x[k]>=0 && b+y[k]<W && b+y[k]>=0){
                            if (S[a+x[k]][b+y[k]]=='.' && v[a+x[k]][b+y[k]]==-1){
                                que.push(pair(a+x[k],b+y[k]));
                                v[a+x[k]][b+y[k]]=v[a][b]+1;
                                n=v[a+x[k]][b+y[k]];
                            }
                        }
                    }
                }
            }
            //cout<<i<<" "<<j<<" "<<n<<endl;
            if (ans<n) ans=n;
        }
    }

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


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include<fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const ll inf = 1LL << 40;

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

    string filename = "result.txt";
    ofstream writing_file;
    writing_file.open(filename, ios::out);

    ll N, K;
    cin >> N >> K;
    vector<multiset<ll>> sushi(N, multiset<ll>());
    Rep (i, N) {
        ll t, d;
        cin >> t >> d;
        t--;
        sushi[t].insert(-d);
    }

    Rep (i, N) {
        if (sushi[i].empty()) sushi[i].insert(inf);
    }

    // Rep (i, N) {
    //     cout << -*sushi[i].begin() << endl;
    // }

    sort(sushi.begin(), sushi.end(), [&](multiset<ll> a, multiset<ll> b) {
        return -*a.begin() > -*b.begin();
    });

    Rep (i, N) {
        writing_file << -*sushi[i].begin() << endl;
    }

    ll cur = 0;
    priority_queue<ll> q;
    Rep (i, K) {
        auto itr = sushi[i].begin();
        cur += -*itr;
        itr++;
        while (itr != sushi[i].end()) {
            q.push(-*itr);
            itr++;
        }
    }

    for (ll i = K; i < N; i++) {
        for (ll e : sushi[i]) {
            q.push(-e);
        }
    }

    ll res = cur + K*K;
    writing_file << K << " " << cur + K*K << "\n";
    for (ll x = K-1; x >= 1; x--) {
        ll v = -*sushi[x].begin();
        ll w = q.top();
        if (v < w) {
            q.pop();
            cur += w;
            q.push(v);
            cur -= v;
        }
        writing_file << x << " " << cur + x*x << "\n";
        res = max(res, cur + x*x);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 17268
N = int(input())
A = list(map(int,input().split()))

print(*A)
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)



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

int main(){
  ll N;
  bool f=true;
  cin>>N;
  vector<pair<ll,ll>> p(N);
  for(ll i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    p.at(i)=make_pair(b,a);
  }
  sort(p.begin(),p.end());
  for(ll i=0;i<N;i++){
    ll a,b;
    tie(b,a)=p.at(i);
    p.at(i)=make_pair(a,b);
  }
  ll x=0;
  for(int i=0;i<N;i++){
    x+=p.at(i).first;
    if(x>p.at(i).second){
      f=false;
      break;
    }
  }
  if(f) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

int main() {
  ll x;
  cin >> x;
  ll ans;
  
  if(x >11){
    ans = (x/11)*2;
    if(1 <= x%11 && x%11 <= 6) ans++;
    else if(7 <= x%11) ans +=2;
  }
  else if(x < 7) ans =1;
  else ans = 2;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S = list(input())
s = 0
num = 0
ans = 0
for i in range(len(S)):
    if i < num:
        continue
    for j in range(1,len(S)-i+1):
        if S[i:i+j] != s:
            s = S[i:i+j]
            num = i+j
            ans += 1
            break
print(ans)

Measured memory_bytes: 4968
// unsolved

#include<bits/stdc++.h>
using namespace std;

//#define DEBUG
#define INF 1000000000
#define REP(i,n) for(int i=0;i<n;i++)
int n;
int a[10002];
int dp[2][5002][2];

int main(){
  cin>>n;
  REP(i,n-1)cin>>a[i+1];
  REP(i,2)REP(j,n/2+1)REP(k,2)dp[i][j][k]=INF;
  dp[0][0][0]=0;
  dp[1][1][1]=0;
  dp[1][0][0]=0;
  REP(i,n){
    REP(j,n/2){
      if(j+1>i)continue;
      dp[(i+1)&1][j+1][0]=min(
        dp[i&1][j+1][0],
        dp[i&1][j+1][1]+a[i]
      );
      if(j>i)continue;
      dp[(i+1)&1][j+1][1]=min(
        dp[i&1][j][0]+a[i],
        dp[i&1][j][1]
      );
    }
    #ifdef DEBUG
    REP(j,n/2){
      cout<<dp[(i+1)&1][j+1][0]<<"/";
      cout<<dp[(i+1)&1][j+1][1]<<" ";
    }
    cout<<endl;
    #endif
  }
  cout<<min(dp[0][n/2][0],dp[0][n/2][1])<<endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var x = double.Parse(Console.ReadLine());

			var i = (-1.0 + Math.Sqrt(1 + 8 * x)) / 2;
			
			if(i - (long)i > 0)
			{
				Console.WriteLine((long)(i + 1));
			}
			else
			{
				Console.WriteLine((long)i);
			}
        }
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll N = 2000000 ;
ll n , m , f[N] , rf[N] , mod = 1e9+7 , ans = 1 ;
ll p ( ll x , ll y ){
    x %= mod ;
    if ( y == 0 ) return 1 ;
    if ( y == 1 ) return x ;
    ll c = p ( x , ( y / 2 ) ) ;
    if ( y % 2 ) return ( ( c * c ) % mod * x ) % mod ;
    else return ( ( c * c ) % mod ) ;
}
int main()
{
    f[0] = rf[0] = 1 ;
    for ( ll i = 1 ; i <= 200222 ; i ++ ){
        f[i] = ( f[i-1] * i ) % mod ;
        rf[i] = p ( f[i] , mod - 2 ) % mod ;
    }
    cin >> n >> m ;
    ll x = m ;
    for ( ll i = 2 ; i <= sqrt ( x ) ; i ++ ){
        ll now = 0 ;
        if ( m % i != 0 ) continue ;
        while ( m % i == 0 ) { m /= i , now ++ ; }
        ll a = n - 1 , b = n - 1 + now ;
        ans = ( ans * ( ( ( f[b] % mod * rf[a] % mod ) % mod ) * rf[b-a] % mod ) % mod ) % mod ;
    }
    if ( m > 1 ){
        ans = ( ans * n ) % mod ;
    }
    cout << ans ;
}


Measured memory_bytes: 5888
import sys
input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0
visited = []

def dfs(i, d, fr):
    global lis, ans, visited
    if visited[i] == 1:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            visited[i] = 1
            # print(i+1 , j+1)
            dfs(j, d+1, i)
            visited[i] = -1


def main():
    global lis, n, m, ans, visited
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(n)]
    visited = [-1] * n
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x;cin >> x;return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n = nxt();

    string s;
    cin >> s;
    ll i = 0;
    while(i < n && s[i] == 'R')i++;
    
    ll j = n - 1;
    while(j >= 0 && s[j] == 'W')j--;
    if(i == n || j == -1){
        cout << 0 << nl;
        return;
    }
    ll w= 0,  r = 0;
    ll len = j - i + 1;
    //deb(i),deb(j);
    for(ll k = i;k<=j;k++){
        if(s[k] == 'W')w++;
        else r++;
    }
    ll ans = min(w, r);
    //deb(r);
    ll ww = 0;
    //deb(i),deb(r);
    for(ll k = i; k < i + r; k++){
        if(s[k] == 'W')ww++;
        //cout << k << " ";
    }
    ans = min(ww, ans);
    ANS;

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3884
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC052A
{
    class Program
    {
        static void Main(string[] args)
        {
            int s,S,A, B, C, D;
 
			var word = Console.ReadLine().Split(' ');
			A = int.Parse(word[0]);
			B = int.Parse(word[1]);
			C = int.Parse(word[2]);
			D = int.Parse(word[3]);
 
			s = A * B; S = C * D;
 
            if (s < S)
            {
                Console.WriteLine(S);
            }
 
            else if (A * B > C * D)
            {
                Console.WriteLine(s);
            }
 
            else if (A * B == C * D)
            {
                Console.WriteLine(s);
            }
               
			Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220