akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            List<Integer> res = new ArrayList<>();
            int lastSwitch = -1;
            for (int i = 0; i <= k; ++i) {
                int nextSwitch = -1;
                for (int j = 0; j < n; ++j)
                    if (j != lastSwitch && (nextSwitch < 0 || a[j] < a[nextSwitch])) {
                        nextSwitch = j;
                    }
                for (int j = 0; j < n; ++j)
                    if (j != lastSwitch && j != nextSwitch) {
                        res.add(j);
                        --a[j];
                        if (a[j] < 0) {
                            out.println(-1);
                            return;
                        }
                    }
                res.add(nextSwitch);
                --a[nextSwitch];
                if (a[nextSwitch] < 0) {
                    out.println(-1);
                    return;
                }
                lastSwitch = nextSwitch;
            }
            out.println(res.size());
            for (int i = 0; i < res.size(); ++i) {
                out.print(res.get(i) + 1 + " ");
            }
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, A;
pair<ll, ll>a[400005] = {}, ans[200005] = {};
queue<ll> qa, qb;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> A;
		a[i] = mp(A, 0);
	}
	rep(i, n) {
		cin >> A;
		a[i + n] = mp(A, 1);
	}
	stable_sort(a, a + 2 * n);
	rep(i, n) {
		if (a[i].second == 0 && a[i + n].second == 0)qa.push(i);
		if (a[i].second == 1 && a[i + n].second == 1)qb.push(i);
		if (a[i].second == 1 && a[i + n].second == 0)swap(a[i], a[i + n]);
		if (a[i].first == a[i + n].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	while (sz(qa)) {
		ll x = qa.front(), y = qb.front();
		qa.pop();
		qb.pop();
		if (a[x].first != a[y + n].first && a[y].first != a[x + n].first) {
			swap(a[x + n].first, a[y + n].first);
			swap(a[y], a[y + n]);
		}
		else {
			swap(a[x + n].first, a[y].first);
		}
	}
	rep(i, n)ans[i] = mp(a[i].first, a[i + n].first);
	stable_sort(ans, ans + n);
	rep(i, n)cout << ans[i].second << endl;
	return 0;
}

Measured memory_bytes: 17756
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int g[3][3];
    for (int i = 0; i < 3; ++i)
    {
      for (int j = 0; j < 3; ++j)
      {
        cin >> g[i][j];
      }
    }
    int n,f = -1;
    cin >> n;
    while(n--)
    { 
      int a;
      cin >> a;
      for (int i = 0; i < 3; ++i)
      {
        for (int j = 0; j < 3; ++j)
        {
          if (g[i][j] == a)
          {
            g[i][j] = 0;
          }
        }
      }      
    }
    for (int i = 0; i < 3; ++i)
    {
      int c = 0; 
      for (int j = 0; j < 3; ++j)
      {
        if (g[i][j] == 0)
        {
          c++;
        }
      }
      if (c == 3)
      {
        f=1;
        break;
      }
    }
    for (int i = 0; i < 3; ++i)
    {
      int c = 0; 
      for (int j = 0; j < 3; ++j)
      {
        if (g[j][i] == 0)
        {
          c++;
        }
      }
      if (c == 3)
      {
        f= 1;
        break;
      }
    }
    if(g[0][0] == 0 && g[1][1] == 0 && g[2][2] == 0)
    {
      f=1;
    }
    if (g[0][2] == 0 && g[1][1] == 0 && g[2][0] == 0)
    {
      f = 1;
    }
    if (f== 1)
    {
      cout << "Yes";
    }
    else
      cout <<"No";
  	return 0;
}	

Measured memory_bytes: 256
#include <cassert>
#include <functional>
#include <iostream>
#include <vector>

auto paint_black(std::vector<std::vector<int>>& v,
                 std::function<bool(int, int)> f) -> void
{
    for (int i = 0; i < v.size(); ++i) {
        auto& v_h = v[i];
        for (int j = 0; j < v_h.size(); ++j) {
            if (!v_h[j]) {
                continue;
            }
            else {
                v_h[j] = !f(i, j);
            }
        }
    }
}

auto print_tile(std::vector<std::vector<int>>& tiles) -> void
{
    std::cout << "----------" << std::endl;
    for (auto& vh : tiles) {
        for (auto& vw : vh) {
            std::cout << vw;
        }
        std::cout << std::endl;
    }
    std::cout << "----------" << std::endl;
}

int main(int argc, char const* argv[])
{
    int w, h, n;
    std::cin >> w >> h >> n;

    auto tiles = std::vector<std::vector<int>>(h, std::vector<int>(w, true));

    // w, h
    // x, y
    for (int i = 0; i < n; ++i) {
        int x, y, a;
        std::cin >> x >> y >> a;
        switch (a) {
            case 1:
                paint_black(tiles, [x](int lh, int lw) -> bool {
                    auto result = lw < x;
                    /* std::cout << lw << " " << lh << " " << x << " " << result
                     * << std::endl; */
                    return lw < x;
                });
                break;
            case 2:
                paint_black(tiles, [x](int lh, int lw) -> bool {
                    auto result = lw > x;
                    /* std::cout << lw << " " << lh << " " << x << " " << result
                     * << std::endl; */
                    return lw >= x;
                });
                break;
            case 3:
                paint_black(tiles, [y](int lh, int lw) -> bool {
                    auto result = lh < y;
                    /* std::cout << lw << " " << lh << " " << y << " " << result
                     * << std::endl; */
                    return lh < y;
                });
                break;
            case 4:
                paint_black(tiles, [y](int lh, int lw) -> bool {
                    auto result = lh > y;
                    /* std::cout << lw << " " << lh << " " << y << " " << result
                     * << std::endl; */
                    return lh >= y;
                });

                break;
            default:
                assert(false && "what is the a?");
        }
        /* print_tile(tiles); */
    }
    int result = 0;
    for (auto& vh : tiles) {
        for (auto& vw : vh) {
            if (vw) {
                result++;
            }
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
from collections import deque

def main():
    dictionary={}
    N,K=map(int,input().split())
    for i in range(K):
        d=int(input())
        A=[int(x) for x in input().split()]
        for num in A:
            if num in dictionary:
                dictionary[num]+=1
            else:
                dictionary[num]=1
                
     
    d=deque()            
    for key in sorted(dictionary.keys()):
        d.append(key)
    
    print(N-len(d))
    
if __name__=="__main__":
    main()


Measured memory_bytes: 9404
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

if a == "H":
	print(b)
else:
	if b == "H":
		print("D")
	else:
		print("H")


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

using namespace std;

const int MAXN = 5e5 + 5;

int n;
int a[MAXN];

int main()
{
        cin>>n;
        for(int i = 0;i<n*2;i++)cin>>a[i];
        int sol = 0;
        sort(a , a+n*2);
        for(int i = 0;i<n*2;i+=2)sol+=a[i];
        cout<<sol;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
ll sum;
int t[1100];
int main(){
    int m,n,p,x;
    cin>>n;
    for(int i=1;i<=n;i++)
        {cin>>t[i];
         sum+=t[i];
        }
    cin>>m;
    for(int j=0;j<m;j++){
        cin>>p>>x;
        cout<<sum-t[p]+x<<endl;
    }
   return 0;
}
//2 1 3



Measured memory_bytes: 256
H, W = map(int, input().split())
C = [[int(x) for x in input().split()] for i in range(10)]
preC = [c[:] for c in C]
for l in range(10):
  postC = [c[:] for c in preC]
  for i in range(10):
    for j in range(10):
      for k in range(10):
        postC[i][j] = min(preC[i][k] + C[k][j], postC[i][j])
  preC = [c[:] for c in postC]
L = [postC[i][1] for i in range(10)]
A = [[int(x) for x in input().split()] for i in range(H)]
ans = 0
for Ai in A:
  for Aij in Ai:
    if Aij > -1:
      ans += L[Aij]
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

namespace TYC
{
	const int N=2e5+10;
	int n,root1,root2,cnt,Head[N],son[N],vis[N*4],ans[N];

	inline int read()
	{
		int x=0,f=0;char ch=getchar();
		while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
		while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
		return f?-x:x;
	}
	
	struct edge
	{
		int to,next,id;
	}E[N*4];
	
	inline void add(int u,int v,int id)
	{
		E[++cnt]=(edge){v,Head[u],id};
		Head[u]=cnt;
		E[++cnt]=(edge){u,Head[v],id};
		Head[v]=cnt;
	}
	
	void dfs(int u,int f)
	{
		for(int i=Head[u];i;i=E[i].next)
		{
			int v=E[i].to;
			if(v==f) continue;
			son[u]++;
			dfs(v,u);
		}
	}
	
	void dfs(int u)
	{
		for(int &i=Head[u];i;i=E[i].next)
		{
			int v=E[i].to,id=E[i].id;
			if(vis[id]) continue;
			vis[id]=1;
			if(u+n==v) ans[u]=1;
			else if(v+n==u) ans[v]=-1;
			dfs(v);
		}
	}
	
	void work()
	{
		n=read();
		int Num=0;
  		for(int i=1;i<=n;i++)
		{
			int f=read();
			if(f==-1) root1=i;
			else add(f,i,++Num);
		}
		for(int i=1;i<=n;i++)
		{
			int f=read();
			if(f==-1) root2=i+n;
			else add(f+n,i+n,++Num);
		}
		dfs(root1,0);
		dfs(root2,0);
		for(int i=1;i<=n;i++)
			if((son[i]&1)!=(son[i+n]&1)) {puts("IMPOSSIBLE");return;}
			else if(!(son[i]&1)) add(i,i+n,++Num);
		puts("POSSIBLE");
		add(0,root1,++Num),add(0,root2,++Num);
		dfs(0);
		for(int i=1;i<=n;i++)
			printf("%d ",ans[i]);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 24704
x1, y1, x2, y2 = map(int, input().split())

dx, dy = x2 - x1, y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)

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

int main(){
    char ch;
    while((ch = getchar()) != EOF){
        if(ch>='a' && ch<='z') ch+='A'-'a';
        else if(ch>='A' && ch<='Z') ch-='A'-'a';
        cout << ch ;
    }
}


Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
    int n,i,cnt=0,p;
    scanf("%d",&n);
    int a[n];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(i!=a[i])
            cnt++;
    }
    if(cnt==2 || cnt==0)
        printf("YES");
    else
        printf("NO");

    return 0;
}


Measured memory_bytes: 1724
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n  <- readInt
  ab <- map toPair <$> readIntLists n
  print $ solve ab n

solve ab n = a - b
 where
  ab' = sortBy (flip (\(a, b) (a', b') -> (a + b) `compare` (a' + b'))) ab
  b   = sum $ map snd $ ab
  a   = sum $ map (\(x, y) -> if odd x then y else 0) $ zipWith
    (\n (x, y) -> (n, x + y))
    [1 ..]
    ab'


Measured memory_bytes: 42364
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

mod = 10**9 + 7

# factorial
factorial = [1,1]
# factorial inverse
factorial_inverse = [1,1]
# inverse for calculation
inverse = [0,1]

for i in range(2, n+1):
    factorial.append((factorial[-1]*i) % mod)
    inverse.append((- inverse[mod % i] * (mod//i)) % mod)
    factorial_inverse.append(factorial_inverse[-1] * inverse[-1] % mod)

def Binominal_theorem(n, k, mod):
    if n < k:
        return 0
    if (n < 0) or (k < 0):
        return 0
    return factorial[n] * factorial_inverse[k] * factorial_inverse[n-k] % mod

ans_min = 0
for i in range(n-k+1):
    ans_min += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

A = A[::-1]
ans_max = 0
for i in range(n-k+1):
    ans_max += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

ans = (ans_max - ans_min) % mod
print(ans)

Measured memory_bytes: 20952
def main():
    N = int(input())
    S = input()
    # flags[n][m]: n 番目の文字と同じ文字がその m 個後にあれば1
    flags = [[0] * N for _ in range(N)]
    for n, c in enumerate(S):
        for m in range(1, N - n):
            if c == S[n + m]:
                flags[n][m] = 1
    ans = 0
    for m in range(1, N):
        from_n = -1
        for to_n in range(N):
            if flags[to_n][m] == 0:
                ans = max(ans, min(m, to_n - from_n - 1))
                from_n = to_n
        if from_n != to_n:
            ans = max(ans, min(m, to_n - from_n - 1))
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 270176
#include "iostream"
#include <vector>

bool exec(std::vector<uint32_t>* p_numberList) 
{
    for (const auto number : *p_numberList) {
        if (number % 2 != 0) {
            return false;
        }
    }

    for (auto& number : *p_numberList) {
        number = number / 2;
    }

    return true;
}

int main()
{
    uint32_t n;
    std::cin >> n;

    std::vector<uint32_t> numberList(n);

    for (auto& number : numberList) {
        std::cin >> number;
    }

    uint32_t counter = 0;
    while(exec(&numberList)){
        counter++;
    }

    std::cout << counter << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int dp[100001];
set<int> st;
void rec(int money) {
  if (dp[money] != INF) return;
  for (auto a : st) if (money-a>=0) dp[money] = min(dp[money], dp[money-a]+1);
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  REP(i, 100001) dp[i] = INF;
  dp[0] = 0;
  dp[1] = 1;
  st.insert(1);
  int six = 1;
  while (six * 6 <= 100000) {
    six *= 6;
    dp[six] = 1;
    st.insert(six);
  }
  six = 1;
  while (six * 9 <= 100000) {
    six *= 9;
    dp[six] = 1;
    st.insert(six);
  }
  int n; cin >> n;
  FOR(i, 2, n+1) rec(i);
  cout << dp[n] << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    int ans = INF;
    REP(i, N){
        int x;
        cin >> x;
        int tmp = 0;
        while(x%2 == 0){
            x /= 2;
            tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << "\n";
    return 0;
}

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

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

using namespace std;

using int64 = int64_t;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string)s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(vector<A> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() {
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

const int mxN = 1010;

int spf[mxN];

void sieve() {
  spf[1] = 1;
  for (int i = 2; i < mxN; i++) {
    spf[i] = i;
  }
  for (int i = 4; i < mxN; i += 2) {
    spf[i] = 2;
  }
  for (int i = 3; i * i < mxN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < mxN; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}

vector<int> getFactorization(int n) {
  vector<int> res;
  while (n != 1) {
    res.emplace_back(spf[n]);
    n = n / spf[n];
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  int n;
  cin >> n;
  const int mod = (int)1e9 + 7;
  vector<int64> cnt(mxN, 0);
  for (int i = 2; i <= n; i++) {
    auto f = getFactorization(i);
    for (auto&& e : f) {
      cnt[e]++;
    }
  }
  debug(cnt);
  int64 ans = 1;
  for (int i = 2; i < mxN; i++) {
    if (cnt[i] > 0) ans *= cnt[i] + 1;
    ans %= mod;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3596
N,K = map(int,input().split())
A = list(map(int,input().split()))
p = [0 for _ in range(N)]
for i in range(N):
    p[A[i]-1] += 1
q = [p[i] for i in range(N) if p[i] != 0]
q.sort()
w = len(q)
print(sum(q[:w-K]))

Measured memory_bytes: 32336
s = list(input())
head = int(s[0] + s[1])
tail = int(s[2] + s[3])

if (head == 0 or 12 < head < 100) and (0 < tail < 13):
    print('YYMM')
elif (0 < head < 13) and (tail == 0 or 12 < tail < 100):
    print('MMYY')
elif (0 < head < 13) and (0 < tail < 13):
    print('AMBIGUOUS')
else:
    print('NA')

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

typedef long long ll;

int main() {
    ll K, r = 0;
    cin >> K;
    rep(i, K) {
        r = (r * 10 + 7) % K;
        if (r == 0) {
            cout << i + 1 << "\n";
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner();
			int n = cin.Int();
			for (int i = 1; i <= 9; i++) {
				for (int j = 1; j <= 9; j++) {
					if (n == i * j) {
						Console.WriteLine("Yes");
						return;
					}
				}
			}

			Console.WriteLine("No");
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
import sys

N, K = map(int, sys.stdin.readline().rstrip().split())

opes = []
for _ in range(N):
    a, b = map(int, sys.stdin.readline().rstrip().split())
    opes.append((a, b))
opes.sort()

count = 0
for (a, b) in opes:
    if count + b >= K:
        print(a)
        sys.exit()
    count += b

Measured memory_bytes: 48220
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while (1 > 0) {
      // 初期入力
      int n = sc.nextInt();// 枚数
      int r = sc.nextInt();// シャッフル回数
      if (n == 0 && r == 0) break;

      // カードの初期化
      int card[] = new int[n];
      for (int i = 0; i < n; i++) {
        card[i] = n - i;
      }

      // シャッフル
      for (int i = 0; i < r; i++) {
        int p = sc.nextInt();// 上からp枚目から
        int c = sc.nextInt();// c枚を一番上に
        // down初期化
        int down[] = new int[p - 1];
        for (int k = 0; k < p - 1; k++) {
          down[k] = card[k];
        }
        // up初期化
        int up[] = new int[c];
        for (int k = 0; k < c; k++) {
          up[k] = card[k + p - 1];
        }
        // シャッフル
        for (int k = 0; k < c; k++) {
          card[k] = up[k];
        }
        for (int k = 0; k < p - 1; k++) {
          card[k + c] = down[k];
        }
      }
      System.out.printf("%d\n", card[0]);
    }
  }
}



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

int main() {
    int n, a, cnt = 0;
    cin >> n;
    vector<int> V;
    for (int i = 0; i < n; i++) {
        cin >> a;
        V.push_back(a);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (V[i] == V[j] || V[i] == V[k] || V[j] == V[k]) {continue;}
                if ((V[i] + V[j] > V[k]) && (V[i] + V[k] > V[j])  && (V[j] + V[k] > V[i])) {cnt++;}
            }
        }
    }
    cout << cnt << endl;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 10000

int main(){

    ll n,wt;
    cin >> n >> wt;

    ll i,j;
    ll w1,v1;
    vector<ll> w;
    vector<ll> v;

    for(i=0;i<n;i++){
        cin >> w1 >> v1;
        w.push_back(w1);
        v.push_back(v1);
    }

    ll dp[n+1][wt+1];

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

    for(i=1;i<=n;i++){
        for(j=1;j<=wt;j++){
            if(w[i-1]>j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
        }
    }
/*
    for(i=0;i<=n;i++){
        for(j=0;j<=wt;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/

    cout << dp[n][wt] << endl;

}


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

import sys
import os
from collections import deque

N = int(input())
q = deque()

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        try:
            q.remove(v)
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()
print(*list(q))

Measured memory_bytes: 48144
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a;
 cin>>a;
 map<int,int>m;
 long long b;
 for(long long i=1;i<a;i++)
 {
     cin>>b;
     m[b]++;
 }
 for(long long j=1;j<=a;j++)
 {
     cout<<m[j]<<endl;
 }
}


Measured memory_bytes: 12952
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  // a ~ b. how many dvisors of c?
  int cnt = 0;
  for(int i = a; i <= b; i++){
    if(c % i == 0){
      cnt++;
    }
  }
  printf("%d\n", cnt);
  //cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>

/*int isprime(int n) {
  for(int i = 2; i * i <= n; i++) {
    if(n % i == 0) return 0;
  }
  return 1;
}

int main(){
  int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, v;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = isprime(i);
  }

  while(scanf("%d", &v) != 0){
    for(int i = v;i > 0;i--){
      if(prime[i] == 1&&prime[i-2] == 1){
          printf("%d %d\n",i-2,i);
          break;
        }
      }
    if(v == 0) break;
  }
  return 0;
}*/

int main() {
  int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, k, v;
  for(i = 2; i <= MAX_V; i++) {
      prime[i] = 1;
    }
      for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
          for(k = 2 * i; k <= MAX_V; k += i) {
            prime[k] = 0;
          }
        }
      }
  while(scanf("%d", &v) != 0){
    for(int i = v;i > 0;i--){
      if(prime[i] == 1&&prime[i-2] == 1){
          printf("%d %d\n",i-2,i);
          break;
        }
      }
    if(v == 0) break;
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int maxn = 2e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


void init() {

}

int a[maxn];
vector<int> E[maxn];
int f[maxn];

int fnd(int x) {
    return x == f[x] ? x : f[x] = fnd(f[x]);
}

void sum(int x,int y)  {
    if (fnd(x) == fnd(y)) return ;
    f[fnd(x)] = fnd(y);
}

int m1[maxn],m2[maxn];
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    int n, k;cin>>n>>k;
    for (int i = 0; i < maxn; i++) f[i] = i;
    for (int i = 1; i <= n; i++) cin>>a[i],m1[a[i]] = i;
    while (k--) {
        int x,y; cin>>x>>y;
        sum(x,y);
    }
    for (int i = 1; i <= n; i++) {
        sum(i,f[i]);
    }
    for (int i = 1; i <= n; i++) {
        //cout<<i<<' '<<f[i]<<endl;
        E[f[i]].push_back(i);
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if(f[i] != i) {
            //res++;
        } else {
            //res--;
            for (int j = 0; j < E[i].size(); j++){
               // cout<<E[i][j]<<' ';
                m2[E[i][j]] = i;
            }
            //cout<<endl;
            for (int j = 0; j < E[i].size(); j++){
                if (m2[a[E[i][j]]] == i) res++;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

int main()

{
    int i,j,k,l,n,m,o,p;
    string a,b,c,d;

    while(cin>>a>>b)
    {
        l=a.size();
        c=a;
        k=0;
        for(j=0;j<l+5;j++)
        {
            if(a==b)
            {
                k=1;
                break;
            }
            else
            {

                c[0]=a[l-1];
                for(i=1; i<l; i++)
                {
                    c[i]=a[i-1];
                }

                a=c;
            }
        }

        if(k==1)
        {
            printf("Yes\n");
        }

        else
        {
            printf("No\n");
        }
    }

}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_program(s) cout << s <<endl;return 0
int kai_size = 120001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size-1) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

int per(int a, int b) {
	int ans = a % b;
	if (ans < 0) { ans += b; }
	return ans;
}
V<pin> uni(V<pin> &v) {
	sor(v);
	V<pin> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i-1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
signed main() {
	int n, l, t; cin >> n >> l >> t; t *= 2;
	vel stay;
	vel move;
	int p0 = -1;
	rep(i, n) {
		int x, w; cin >> x >> w;
		if (w == 1) { stay.push_back(x); if (p0 == -1) { p0 = i; } }
		else { move.push_back(x); }
	}
	if (stay.size() == 0) {
		rep(i, n) {
			cout << per(move[i] - t / 2, l) << endl;
		}
		return 0;
	}
	int c0 = stay[0];
	rep(i, stay.size()) {
		stay[i] = per(stay[i] - c0, l);
	}
	rep(i, move.size()) {
		move[i] = per(move[i] - c0, l);
	}
	sor(stay);
  	sor(move);
	int ind = move.size();
	ind *= t / l;
	int ext = t % l;
	ind += (lower_bound(move.begin(), move.end(), ext) - move.begin());
	ind = per(-ind, n);
	vel ans;
	for (auto x : stay) {
		ans.push_back(x);
	}
	for (auto x : move) {
		ans.push_back(per(x - t, l));
	}
	sor(ans);
	t = t / 2;
	rep(i, n) {
		cout << (ans[(i + ind+n-p0) % n]+t+c0)%l << endl;
	}
	return 0;
}


Measured memory_bytes: 4800
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():

    class WeightedUnionFind():
        def __init__(self, n):
            self.nodes = [-1 for _ in range(n)]
            self.weight = [0] * n

        def get_root(self, x):
            if self.nodes[x] < 0:
                return x
            else:
                y = self.get_root(self.nodes[x])
                self.weight[x] += self.weight[self.nodes[x]]
                self.nodes[x] = y
                return y

        def unite(self, x, y, w):
            w += self.weight[x]-self.weight[y]
            root_x = self.get_root(x)
            root_y = self.get_root(y)
            if root_x != root_y:
                # 大きい木の方につないだほうが計算量が減る
                if self.nodes[root_x] > self.nodes[root_y]:
                    root_x, root_y = root_y, root_x
                    w *= -1
                self.nodes[root_x] += self.nodes[root_y]
                self.nodes[root_y] = root_x
                self.weight[root_y] = w

        def diff(self, x, y):
            return self.weight[y] - self.weight[x]

        def same(self, x, y):
            return get_root(x) == get_root(y)
    N, M = MI()
    edge = [[] for _ in range(N)]
    uf = WeightedUnionFind(N)
    get_root, unite, nodes, diff, same = uf.get_root, uf.unite, uf.nodes, uf.diff, uf.same
    distanse = [0] * N
    distanse[0] = 0
    rev_edge = [[]for _ in range(N)]
    for _ in range(M):
        l, r, d = MI_()
        d += 1
        edge[l].append((r, d))
        if same(l, r) and diff(l, r) != d:
            print("No")
            exit()
        else:
            unite(l, r, d)

    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 138528
#include<iostream>
#include<cmath>

int main() {
	long long X, K, D;
	std::cin >> X >> K >> D;
	X = std::abs(X);

	long long ans;

	if (X / D >= K) {
		ans = X - K * D;
		std::cout << ans << std::endl;
		return 0;
	}

	long long A = K - X / D;
	if (A % 2 == 0) {
		ans = X - X / D * D;
	}
	else {
		ans = (X / D + 1) * D - X;
	}

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

	return 0;
}

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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

int n;

void solve(){
	cin >> n;
	int ans = 0;
	/*
	while(n>0){
		int sum = 0;
		for(int i=1;i*i<=n;i++){
			if(n%i==0){
				sum += (i*i==n ? 1 : 2);
			}
		}
		ans += sum;
		n--;
	}
	*/
	n--;
	for(int i=1;i<=n;i++){
		//if(i*i<=n)
			//ans--;
		ans += (n/i);
		//cout << i << " : " << ans << '\n';
	}
	cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


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

int main() {
  string S;
  int K;
  cin >>K>>S;
  if(S.size()<=K){cout<<S<<endl;}
  else {
    for(int i=0 ;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}


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

using namespace std;
const int MAXN = 2e5 + 5;
typedef long long LL;

int a[MAXN];

int cmp(int a, int b) {
    return a > b;
}

int main(int argc, char* argv[]) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    sort(a, a + n, cmp);
    LL ans = a[0];
    for (int i = 1; i < n / 2; i++)
        ans += 2 * a[i];
    if (n % 2 == 1) ans += a[n / 2];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4504
import fractions
a,b,c,d = map(int,input().split())
c_val = (b // c) - ((a - 1) // c)
d_val = (b // d) - ((a - 1) // d)
cd_gcd = fractions.gcd(c, d)
cd_lcm = c * d // cd_gcd
cd_lcm_val = (b // cd_lcm) - ((a - 1) // cd_lcm)
cd_val = c_val + d_val - cd_lcm_val
print((b - a + 1) - cd_val)

Measured memory_bytes: 5052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int d, e;

int main() {
	while (cin >> d >> e) {
		if (!d) break;
		double ans = 1e+9;
		for (int x = 0; x <= d; x++) {
			int y = d - x;
			ans = min(ans, abs(sqrt((double)x * x + y * y) - e));
		}
		printf("%.14f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3128
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			while(true)
			{
				var md = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				if(md[0] == 0)
					return;
				var date = new DateTime(2004, md[0], md[1]);
				Console.WriteLine(date.DayOfWeek.ToString("f"));
			}
		}
	}
}

Measured memory_bytes: 20576
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007
 
using namespace std;
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b <=c || d <=a)
    {
        cout << 0 << endl;
    }
    else if (a <=c && c <=d && d <=b)
    {
        cout << d - c << endl;
    }
    else if (c <=a && a <=b && b <=d)
    {
        cout << b - a << endl;
    }
    else if (a <=c && c <=b && b <=d)
    {
        cout << b - c << endl;
    }
    else if (c <=a && a <=d && d <=b)
    {
        cout << d - a << endl;
    }
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    for (;;) {
        c -= b;
        if (c <= 0) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            puts("No");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn keta(n: usize) -> usize {
   let mut x = n;
   let mut c = 0;
   while x > 0 {
      x /= 10;
      c += 1;
   }
   c
}

fn main() {
   input! {
      n: usize,
   }
   let mut ans = keta(n);
   let mut i = 2;
   while i*i <= n {
      if n%i == 0 {
         ans = std::cmp::min(ans, keta(n/i));
      }
      i += 1;
   }
   println!("{}", ans);
}


Measured memory_bytes: 4352