akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = apply2 (*) <$> getInts >>= print


Measured memory_bytes: 3612
use std::str::FromStr;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<u32>(n);
    let b = i.read_vec::<u32>(n);

    writeln!(o, "{}", solve(a, b)).unwrap();
}
fn solve(a: Vec<u32>, mut b: Vec<u32>) -> u32 {
    let n = a.len();
    let mut result = 0;
    let mut mask = 0;
    for i in 0..29 {
        mask |= 1 << i;
        b.sort_by_key(|x| x & mask);

        let t1 = 1 << i;
        let t2 = 1 << (i + 1);
        let t3 = t1 + t2;
        let mut has_bit = false;
        for &a in &a {
            let j1 = b.lower_bound_by(|&b| (a & mask) + (b & mask) >= t1);
            let j2 = b.lower_bound_by(|&b| (a & mask) + (b & mask) >= t2);
            let j3 = b.lower_bound_by(|&b| (a & mask) + (b & mask) >= t3);
            if ((n - j3) + (j2 - j1)) % 2 == 1 {
                has_bit = !has_bit;
            }
        }
        if has_bit {
            result |= 1 << i;
        }
    }
    result
}

pub trait BinarySearchExt<T> {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearchExt<T> for [T] {
    fn lower_bound_by<F: Fn(&T) -> bool>(&self, f: F) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low < high {
            let mid = (low + high) / 2;
            if f(&self[mid]) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        low
    }
    fn lower_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y < x)
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.lower_bound_by(|y| y <= x)
    }
}

mod utils {
    use super::*;
    use std::ops::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a,b,c,d;
    t = 1;
    while(t--) {
     cin >> a >> b >> c >> d;
     if(a + b > c + d)
      cout << "Left" << endl;
     else if(a + b == c + d)
      cout << "Balanced" << endl;
     else
      cout << "Right" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

char c[1000000];
string s;

signed main()
{
    getline( cin, s );
    int  i = 0;
    while( i != s.size() )
    {
        printf( "%c", toupper( s[i] ) );
        i++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3156
#[allow(unused_imports)]
use std::io::Write;

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

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

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

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

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

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

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

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

#[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()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![W: f64, H: f64, x: f64, y: f64];
    let min_area = W * H / 2.0;
    let ans = if x + x == W && y + y == H { 1 } else { 0 };
    println!("{} {}", min_area, ans);
}


Measured memory_bytes: 2220
def getCount(nums):
    cnt = 1
    mmin = nums[0]
    for i in range(1,len(nums)):
        if nums[i] < mmin:
            cnt+=1
        mmin = min(nums[i],mmin)
    return cnt    

n = input()
nums = list(map(int, input().split(" ")))
print(getCount(nums))



Measured memory_bytes: 24744
#include<stdio.h>
#define N 5

main(){
  int i, j, max, a, data[N];

  for(i=0; i<N; i++)
    scanf("%d", &data[i]);

  for(i=0; i<N-1; i++){
    max = i;
    for(j=i+1; j<N; j++){
      if(data[j] > data[max]){
        max = j;
      }
    }
    a = data[max];
    data[max] = data[i];
    data[i] = a;
  }

  for(i=0; i<N-1; i++){
    printf("%d ", data[i]);
  }
  printf("%d\n", data[N-1]);

  return 0;
}

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

signed main() {
    int n, m, ans = 0;
    string s, t;
    map<string, int> str1, str2;
    vector<string> dic;

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> s;
        str1[s] ++;
        dic.push_back(s);
    }
    cin >> m;
    for ( int i = 0; i < m; i++ ) {
        cin >> t;
        str2[t] ++;
        dic.push_back(t);
    }

    ans = 0;
    for ( int i = 0; i < n+m; i++ ) {
        ans = max(ans, str1[dic[i]] - str2[dic[i]]);
    }

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

Measured memory_bytes: 3580
///
// File:  1608.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 22:59:44 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    vector<uint32_t> points;
    for (uint32_t i = 0; i < n; i++) {
      uint32_t val;
      cin >> val;
      points.push_back(val);
    }

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

    uint32_t min_diff = UINT32_MAX;
    for (uint32_t i = 0; i < points.size() - 1; i++) {
      uint32_t diff = points[i + 1] - points[i];
      min_diff = min(min_diff, diff);
    }

    cout << min_diff << endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>

int main(){
 char a[5];
 scanf("%s",a);
 if(a[1] == a[2] && a[0] == a[1]){
  printf("Yes");
 } else if(a[1] == a[2] && a[2] == a[3]){
  printf("Yes");
 } else{
  printf("No");
 }
 return 0;
}

Measured memory_bytes: 128
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 15:15:02
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  int k; cin >> k;
  // x, y
  // white : (n - x) * (m - y) + x * y
  // black : n * m - white
  
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (n * m - (n - i) * (m - j) - i * j == k) {
        cout << "Yes" << endl; return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define debug(arr) cout << ">>" << #arr << ':' << arr << endl;
#define endl "\n"
#define pb push_back
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin() , v.end()
int gcd(int a,int b){
	while(a&&b)a>b?a%=b:b%=a;
	return a+b;
}

const int N = 200001;
	

int main()
{
	IOS
	int n;
	cin>>n;
	string s;
	cin>>s;
	int idx=0;
	int st=0;
	for(int i=s.length()-1 ; i>=0 ; i--)
	{
		if(s[i] == 'R')
		{
			idx = i;
			break;
		}
	}
	
	for(int i=0 ; i<n ; i++)
	{
		if(s[i] == 'W')
		{
			st = i;
			break;
		}
	}
	int count=0;
	
	for(int i=st  ; i<s.length() ; i++)
	{
		if(idx <= i)break;
		if(s[i] == 'W')
		{
			for(int j = idx ; j>i ; j--)
			{
				if(s[j] == 'R')
				{
					swap(s[i] , s[j]);
					count++;
					idx = j;
					break;
				}
			}
		}
	}
	cout<<count<<endl;
	
	
}

Measured memory_bytes: 3780
#include"bits/stdc++.h"
using namespace std;

void Main() {
  long long int x, y;
  cin >> x >> y;

  long long int ans = 0;
  while (x <= y) {
    x *= 2;
    ans++;
  }

  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

const ll MOD = 1000000007;

vector<ll> primes;
void init_primes(ll N)
{
    vector<bool> is_prime(N+1, true);
    is_prime[0] = is_prime[1] = false;
    rep(i, 2, N+1)
    if (is_prime[i])
    {
        primes.push_back(i);
        for (ll j = (ll)i*i; j<=N; j += i)
            is_prime[j] = false;
    }
}

ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m > 0)
    {
        if (m&1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        m >>= 1;
    }
    return res;
}

ll inv_mod(ll n)
{
    return power_mod(n, MOD-2);
}

vector<ll> factorials;
void init_factorial(ll N)
{
    factorials.assign(N+1, 1);
    rep(i, 2, N+1)
    {
        factorials[i] = factorials[i-1] *i;
        factorials[i] %= MOD;
    }
}

ll comb(ll n, ll m)
{
    m = min(m, n-m);
    ll res = factorials[n];
    debug(n, factorials[n]);
    res *= inv_mod(factorials[n-m]);
    res %= MOD;
    res *= inv_mod(factorials[m]);
    res %= MOD;
    debug(n, m, res);
    return res;
}

int main()
{
    // init primes
    init_primes(200010);
    init_factorial(200010);
    debug(primes);

    // read data
    int N, M;
    cin >> N >> M;

    ll ans = 1;
    for (auto prime: primes)
    {
        // decompose
        ll cnt = 0;
        while (M%prime==0)
        {
            ++cnt;
            M /= prime;
        }
        if (cnt == 0) continue;

        // cnt 
        debug(M, prime, cnt, ans);
        ans *= comb(cnt+N-1, N-1);
        ans %= MOD;
    }
    if (M>1)
    {
        ans *= N;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2152
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  if (a <= b){
    cout << a << '\n';
  }
  else{
    cout << a-1 << '\n';
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 13924
h, w = map(int, input().split())
n = int(input())
l = list(map(int, input().split()))

ans = []
for i in range(n):
  ans += [i+1]*l[i]

for i in range(h):
  temp = ans[i*w:(i+1)*w]
  if i%2 == 0:
    print(*temp)
  else:
    temp = reversed(temp)
    print(*temp)

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

int main(){
    map<string,int> word;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        if(word.count(str)){
            word.at(str) ++;
        }else{
            word[str] = 1;
        }
    }
    int m = 0;
    for(auto x:word){
        if(m < x.second) m = x.second;
    }
    for(auto x:word){
        if(x.second == m) cout << x.first << endl;
    }
}

Measured memory_bytes: 19180
#ベルマンフォード法
#正の閉路がない時は普通のベルマンフォード法
n,m=list(map(int,input().split()))
es=[]
for i in range(m):
  a,b,c=list(map(int,input().split()))
  es.append((a-1,b-1,c))
import sys
def Bellmanford(n,m,s,es):
  d=[-float("INF")]*n
  d[s]=0
  cnt=0
  while(1):
    update=False
    for p,q,r in es:
      if d[p]!=-float("INF") and d[q]<d[p]+r:
        d[q]=d[p]+r
        update=True
    cnt+=1
    if not update:
      break
    if cnt==n-1:
      memo=d[n-1]
    if cnt==n+1:
      #正のループがある
      if d[n-1]>memo:
        print(float("INF"))
        sys.exit()
      else:
        print(memo)
        sys.exit()
  print(d[n-1])
  
Bellmanford(n,m,0,es)  
    
    
      
  
  

  

Measured memory_bytes: 75368
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    data=sort([parseMap(split(readline())) for _ in 1:n],by=x->x[1])
    cnt=0
    for i in 1:n
        cnt+=data[i][2]
        if cnt>=k
            println(data[i][1])
            break
        end
    end
end
main()

Measured memory_bytes: 176256
from math import gcd



k = int(input())
ans = 0

temp = []
for i in range(1,k+1):
  for j in range(1,k+1):
    temp.append(gcd(i,j))

import collections
c = collections.Counter(temp)

for i in range(1,k+1):
  for j in c.keys():
    ans += gcd(i,j) * c[j]

print(ans)

Measured memory_bytes: 9684
n = int(input())
count = 0
for z in range(1,n+1):
	if not z%2 or z <= 104:
		continue
	y = 0
	for i in range(1,z+1):
		if z%i == 0:
			y += 1	
	if y == 8:
		count += 1
print(count)	


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

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

	int n, t;
	cin >> n;

	int ten = 0, sum = 0, mini = 999;
	while (n--) {
		cin >> t;
		if (t % 10 == 0) ten += t;
		else {
			sum += t;
			mini = min(mini, t);
		}
	}

	if (mini == 999) cout << 0;
	else {
		if (sum % 10 == 0) sum -= mini;
		cout << ten + sum;
	}
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/07/29  Problem: ARC 079 B / Link: http://arc079.contest.atcoder.jp/tasks/arc079_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;

ll ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
		ll K;
		cin >> K;
		N = 50;
		ll lef = K%N;
		ll div = K / N;

		assert(lef + div*N == K);

		cout << N << endl;
		FOR(i, 0, N) {
			ans = div;
			if (i <lef)ans +=1;
			ll sita = ans*(N + 1) - K;
			ll ue = ans*(N + 1) - K + N;
			ll x = sita;
			ll shi = 1;// ue - sita;
			while (shi * 2 < ue - sita)shi *= 2; shi *= 2;
			while (1) {
				if (shi == 0)break;
				if (x + shi < ue/*&&(x+shi<=(1e16+1000))*/) {
					x += shi;
				}
				shi /= 2;
			}
			assert(x >= 0 && x <= (1e16 + 1000));
			cout << x << " ";
		}
		cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int A, B, C, K;
  int ans = 0;
  scanf("%d%d%d%d", &A, &B, &C, &K);

  if (A > K)
  {
    ans += 1 * K;
    printf("%d\n", ans);
    return 0;
  }
  else
  {
    ans += 1 * A;
  }
  K -= A;

  if (B > K)
  {
    ans += 0 * K;
    printf("%d\n", ans);
    return 0;
  }
  else
  {
    ans += 0 * B;
  }
  K -= B;

  if (C > K)
  {
    ans += -1 * K;
    printf("%d\n", ans);
    return 0;
  }
  else
  {
    ans += -1 * C;
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 1692
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()

bus = 0
kyaku = 0
dep_time = 0
for t in T:
    if t > dep_time or kyaku == C:
        dep_time = t + K
        kyaku = 1
        bus += 1
    else:
        kyaku += 1

print(bus)

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい

int main(){
  faster();
  ll n,sum=0;
  cin >> n;
  sum = n*(n+1)/2;
  for(ll i=1;i<=n;i++){
    if(!(i%3)) sum -= i;
    if(!(i%5)) sum -= i;
    if(!(i%15)) sum += i;
  }
  cout << sum << endl;
}























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

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

using namespace std;

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

  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vector<vector<int>> ans(n, vector<int>(m));
  for (int i = 0; i < b; ++i) {
    for (int j = a; j < m; ++j) {
      ans[i][j] = 1;
    }
  }
  for (int i = b; i < n; ++i) {
    for (int j = 0; j < a; ++j) {
      ans[i][j] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << ans[i][j];
    }
    cout << '\n';
  }
  
  return 0;
}

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

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

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

    int now = 1;
    for(int i = 0; i < n; i++){
        if(A[i] == now){
            now++;
        }
    }

    if(now == 1){
        cout << -1 << endl;
    }else{
        cout << n - now + 1 << endl;
    }


    return 0;
}

Measured memory_bytes: 1024
/*
  AtCoder Beginner Contest 078
  C - HSI

  方針

  実装

*/

#include<iostream>
#include<cmath>
using namespace std;

int N, M;

int main() {
  scanf("%d %d", &N, &M);
  
  int times = (int)(pow(2, M) + 0.5);

  printf("%d\n", times * (1900 * M + 100 * (N - M)));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, l, r, count=0;
    cin>>N;
    rep(i, N){
        cin>>l>>r;
        count+=(r-l+1);
    }
    cout<<count<<endl;
    return 0;
}


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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

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

LL s(vector<LL> &v, LL b) {
    LL sum = 0;
    REP(i, v.size()) sum += abs(v[i] - (b + (LL)i + 1));
    return sum;
}

void solve(__attribute__((unused)) int tc = 0) {
    int n;
    LL x;
    cin >> n;

    vector<LL> v;
    REP(_, n) { cin >> x; v.pb(x); }

    LL l = -1e9;
    LL r = 1e9;

    while (l < r) {
        LL b = (l + r) / 2;
        LL sum1 = s(v, b);
        LL sum2 = s(v, b - 1);
        debug(sum1, sum2, l, r);
        if (sum1 < sum2) l = b;
        else r = b - 1;
        if (r - l == 1) break;
    }

    cout << min(s(v, l), s(v, r)) << endl;

    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    Jewel;
    int a, b, c;
    cin>>a>>b>>c;
    if((a==b)&&(a!=c) || (a==c)&&(a!=b) || (b==c)&&(a!=b) )
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    ll x,y;
    cin>>x>>y;
    int i=1;
    if(x%y==0){
        cout<<-1<<endl;
        return 0;
    }else{
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
lines = readlines.map(&:strip)

n = lines[0].to_i
red_points = lines[1..n].map{|e|e.split.map(&:to_i)}
blue_points = lines[n+1..n*2].map{|e|e.split.map(&:to_i)}

red_points.sort!
blue_points.sort!


blue_points.each do |blue|
  candidate = red_points.select{|red|red[0] < blue[0] && red[1] < blue[1]}.sort_by{|red|red[1]}.last
  red_points.delete(candidate)
end

puts n-red_points.count



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  double pi = acos(-1);
  double rad = c * pi / 180;
  double s = a * b * sin(rad) / 2;
  double l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
  double h = b * sin(rad);
  cout << fixed << setprecision(10);
  cout << s << " " << l << " " << h << endl;
  /*
  c = sqrt(a * a + b * b)
  c * c = a * a + b * b;
  */
}


Measured memory_bytes: 3524
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    long sum=0;
    cin >> n;
    vector<int> A(n+1), B(n);

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

    for(int i=0;i<n;i++){
        if(B[i] <= A[i]){
            sum += B[i];
        }
        else{
            B[i] -= A[i];
            sum += A[i];
            if(B[i] <= A[i+1]){
                sum += B[i];
                A[i+1] -= B[i];
            }
            else{
                sum += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 5e2 + 5;

struct Node
{
	int x,y;
};

int s[MAXN],t[MAXN];
ull u[MAXN],v[MAXN];

ull ans[MAXN][MAXN];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&s[i]);
	for(int i=1; i<=n; ++i) scanf("%d",&t[i]);
	for(int i=1; i<=n; ++i) scanf("%llu",&u[i]);
	for(int i=1; i<=n; ++i) scanf("%llu",&v[i]);
	
	try
	{
		for(int k=0; k<64; ++k)
		{
			static int p[MAXN],q[MAXN];
			for(int i=1; i<=n; ++i)
				p[i] = (u[i]>>k)&1,
				q[i] = (v[i]>>k)&1;
			
			static int a[MAXN][MAXN];
			static bool must[MAXN][MAXN];
			static bool delr[MAXN], delc[MAXN];
			static queue<Node> que;
			
			memset(must,0,sizeof(must));
			memset(delr,0,sizeof(delr));
			memset(delc,0,sizeof(delc));
			
			for(int i=1; i<=n; ++i)
			{
				if(s[i] == p[i]) continue;
				for(int j=1; j<=n; ++j)
				{
					if(must[i][j] && a[i][j]!=p[i]) throw 114514;
					a[i][j]=p[i]; must[i][j]=1;
					que.push((Node){i,j});
				}
				delr[i]=1;
			}
			for(int j=1; j<=n; ++j)
			{
				if(t[j] == q[j]) continue;
				for(int i=1; i<=n; ++i)
				{
					if(must[i][j] && a[i][j]!=q[j]) throw 114514;
					a[i][j]=q[j]; must[i][j]=1;
					que.push((Node){i,j});
				}
				delc[j]=1;
			}
			
			while(!que.empty())
			{
				int x=que.front().x, y=que.front().y;
				que.pop();
				
				if(!delr[x])
				{	
					if(!must[x][y])
					{
						a[x][y] = p[x];
						must[x][y]=1;
					}
					if(p[x] == a[x][y])
					{
						for(int j=1; j<=n; ++j)
							que.push((Node){x,j});
						delr[x]=1;
					}
				}
				if(!delc[y])
				{
					if(!must[x][y])
					{
						a[x][y] = q[y];
						must[x][y]=1;
					}
					if(q[y] == a[x][y])
					{
						for(int i=1; i<=n; ++i)
							que.push((Node){i,y});
						delc[y]=1;
					}
				}
			}
			
			int r=0,c=0;
			for(int i=1; i<=n; ++i)
				if(!delr[i]) ++r;
			for(int i=1; i<=n; ++i)
				if(!delc[i]) ++c;
			
			if(r==1)
			{
				for(int i=1; i<=n; ++i)
					for(int j=1; j<=n; ++j)
					{
						if(!must[i][j])
							a[i][j] = q[j];
					}
			}
			if(c==1)
			{
				for(int i=1; i<=n; ++i)
					for(int j=1; j<=n; ++j)
					{
						if(!must[i][j])
							a[i][j] = p[i];
					}
			}
			if(r>1 && c>1)
			{
				for(int i=1,tmp=0; i<=n; ++i) if(!delr[i])
				{
					for(int j=1,now=tmp; j<=n; ++j) if(!delc[j])
					{
						a[i][j] = now;
						now^=1;
					}
					tmp^=1;
				}
			}
			
			for(int i=1; i<=n; ++i)
			{
				int ann=1, orr=0;
				for(int j=1; j<=n; ++j)
					ann&=a[i][j], orr|=a[i][j];
				if(s[i]==0 && ann!=p[i]) throw 114514;
				if(s[i]==1 && orr!=p[i]) throw 114514;
			}
			for(int j=1; j<=n; ++j)
			{
				int ann=1, orr=0;
				for(int i=1; i<=n; ++i)
					ann&=a[i][j], orr|=a[i][j];
				if(t[j]==0 && ann!=q[j]) throw 114514;
				if(t[j]==1 && orr!=q[j]) throw 114514;
			}
			
			for(int i=1; i<=n; ++i)
				for(int j=1; j<=n; ++j)
					ans[i][j] |= ((ull)a[i][j]<<k);
		}
	}
	catch(...)
	{
		printf("-1");
		return 0;
	}
	
	for(int i=1; i<=n; ++i,putchar('\n'))
		for(int j=1; j<=n; ++j) printf("%llu ",ans[i][j]);
	return 0;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;


void insert(int key){

    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    y = NIL;
    x = root;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == NIL) root = z;
    else if(z->key < y->key)y->left = z;
    else y->right = z;
}

void preorder(Node *node){
    if(node == NIL) return ;
    cout << " " << node->key;
    if(node->left != NIL) preorder(node->left);
    if(node->right != NIL) preorder(node->right);
}

void inorder(Node *node){
    if(node == NIL) return;
    if(node->left != NIL) inorder(node->left);
    cout << " " << node->key;
    if(node->right != NIL) inorder(node->right);
}

void print(){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

int main(){
    int i, m, key;

    string command;

    cin >> m;
    for(i = 0; i < m ; i++){
        cin >> command;
        if(command[0] == 'i'){
            cin >> key;
            insert(key);
        } else{
            print();
        }
    }
    return 0;
}


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

using namespace std;

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

typedef modint<1000000007> mint;

mint comb(int n, int m) {
  mint ret = 1;
  n = n - m;
  for (int i = 1; i <= m; i++) {
    ret *= n + i;
    ret /= i;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, int> prime;
  prime[2] = 0;
  prime[3] = 0;
  for (int i = 5; i * i<= m; i += 2) {
    bool is = true;
    for (int j = 3; j * j <= i; j += 2) {
      if (i % j == 0) {
        is = false;
        break;
      }
    } 
    if (is) {
      prime[i] = 0;
    }
  }
  for (auto p: prime) {
    int num = p.first;
    while (m % num == 0) {
      m /= num;
      prime[num]++;
    }
  }
  if (m != 1) {
    prime[m] = 1;
  }
  mint ans = 1;
  for (auto p: prime) {
    if (p.second == 0) {
      continue;
    }
    ans *= comb(n + p.second - 1, p.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<"A"<<s2[0]<<"C\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll N, M, R;
VVL d;
VL r;

ll dfs(map<ll, bool> cand, ll now, ll dist){
    ll ret = 1e18, cnt = 0;
    for(auto e : r){
        if(!cand[e]) continue;
        cand[e] = false;
        ret = min(ret, dfs(cand, e, dist + d[now][e]));
        cand[e] = true;
        cnt++;
    }
    if(cnt == 0) return dist;
    return ret;
}

int main(){
    cin >> N >> M >> R;
    
    r.resize(R);
    rep(i, 0, R){
        cin >> r[i];
        r[i]--;
    }

    d.resize(N, VL(N, 1e18));
    rep(i, 0, M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(i, 0, N) d[i][i] = 0;
    rep(i, 0, N){
        rep(j, 0, N){
            rep(k, 0, N){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    cerr << "toki" << endl;
    ll ans = 1e18;

    map<ll, bool> ca;
    for(auto e : r) ca[e] = true;
    for(auto e : r){
        ca[e] = false; 
        ans = min(ans, dfs(ca, e, 0));
        ca[e] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=105,MX=1000*N;
ll w[N],v[N],n,cap,dp[N][MX];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>cap;
    for(ll i=1;i<=n;i++)cin>>w[i]>>v[i];
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<MX;j++){
            dp[i][j]=dp[i-1][j];
            if(j-v[i]>=0)dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
        }
    }
    for(ll i=MX;;i--)if(dp[n][i]<=cap)return cout<<i , 0;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    string s;
    cin>>s;
    int n=s.length();
    vector<int>v;
    int temp=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            temp++;
        else
        {
            v.push_back(temp);
            temp=1;
        }
    }
    v.push_back(temp);
    int ans=0;
    for(int i=0;i<v.size()-1;i++)
    {
        if(v[i]==0)
            continue;
        int val=v[i];
        if(val%3==1)
        {
            ans+=((val/3)*2+1);
        }
        else if(val%3==0)
        {
            ans+=(val/3)*2;
        }
        else{
            v[i+1]--;
            val++;
            ans+=(val/3)*2;
        }
    }
    int val=v[v.size()-1];
    if(val%3==1)
    {
        ans+=((val/3)*2+1);
    }
    else if(val%3==0)
    {
        ans+=(val/3)*2;
    }
    else{
        ans+=(val/3)*2+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5500
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

struct P{
	int x;
	int y;
};

struct St{
	P ln;
	P rn;
};

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};

bool bfs(char la[51][51], char ra[51][51], int w, int h, P len, P rin)
{
	bool f = false, vis[51][51][51][51];
	fill(&vis[0][0][0][0], &vis[50][50][50][50], true);
	St s, t;
	P l, r, u, v;
	queue<St> que;
	s.ln = len;
	s.rn = rin;
	que.push(s);
	vis[len.y][len.x][rin.y][rin.x] = false;
	while(!que.empty()){
		s = que.front();
		que.pop();
		l = s.ln;
		r = s.rn;
		if(la[l.y][l.x] == '%' && ra[r.y][r.x] == '%'){
			f = true;
			break;
		}
		if(la[l.y][l.x] == '%' || ra[r.y][r.x] == '%'){
			continue;
		}
		
		for(int i = 0; i < 4; i++){
			u.y = l.y+ydir[i];
			u.x = l.x+xdir[i];
			v.y = r.y+ydir[i];
			v.x = r.x-xdir[i];
			if(u.y < 0 || u.y >= h || u.x < 0 || u.x >= w){
				u.y = l.y;
				u.x = l.x;
			}
			if(la[u.y][u.x] == '#'){
				u.y = l.y;
				u.x = l.x;
			}
			if(v.y < 0 || v.y >= h || v.x < 0 || v.x >= w){
				v.y = r.y;
				v.x = r.x;
			}
			if(ra[v.y][v.x] == '#'){
				v.y = r.y;
				v.x = r.x;
			}
			if(vis[u.y][u.x][v.y][v.x]){
				vis[u.y][u.x][v.y][v.x] = false;
				t.ln = u;
				t.rn = v;
				que.push(t);
			}
		}
	}
	
	return f;
}

int main()
{
	int w, h;
	char ra[51][51], la[51][51];
	P rin, len;
	
	while(cin>>w>>h && (w+h)){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> la[i][j];
				if(la[i][j] == 'L'){
					len.y = i;
					len.x = j;
				}
			}
			
			for(int j = 0; j < w; j++){
				cin >> ra[i][j];
				if(ra[i][j] == 'R'){
					rin.y = i;
					rin.x = j;
				}
			}
		}
		
		if(bfs(la, ra, w, h, len, rin)){
			cout << "Yes"<< endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 8412
#include<stdio.h>
#include<string.h>

int main()
{
  char s[11], t[11], u[11];
  int numS, numT;
  scanf("%s %s", s, t);
  scanf("%d %d", &numS, &numT);
  scanf("%s", u);
  
  if (strcmp(s, u) == 0)
  {
    numS--;
  }
  else
  {
    numT--;
  }
  
  printf("%d %d", numS, numT);
  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
C - Monsters Battle Royale
https://atcoder.jp/contests/abc118/tasks/abc118_c

"""
import sys


def solve(monsters):
    monsters = set(monsters)
    min_v = min(monsters)
    while len(monsters) > 1:
        monsters = set([m%min_v for m in monsters if m%min_v])
        monsters.add(min_v)
        min_v = min(monsters)
    return min(monsters)


def main(args):
    N = int(input())
    monsters = [int(m) for m in input().split()]
    ans = solve(monsters)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main() {
	int N;

	cin >> N;
	if (N<30) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c = sc.next();
    String ans = "consonant";
    if(c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") || c.equals("u")) ans = "vowel";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
import sys
x = []
for line in sys.stdin:
    h,w = line.split()
    h,w = int(h), int(w)
    if h == 0 and w== 0: break
    tmp = (w+1)/2
    s1 = ('.#' * tmp)[:w]
    s2 = ('#.' * tmp)[:w]
    for j in range(h):
        if (j & 1)==0: s = s2
        else: s = s1
        print s
    print
    

Measured memory_bytes: 4232
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

//#define LengthOf()

#if 1
//No 4
LLONG Hoge(INT* runrunCnt, INT K, char number[256], INT len, INT idx)
{
	LLONG ret = 0;

	//数字が完成
	if (idx == len) {
		*runrunCnt += 1;
#if 0
		{
			LLONG tmp = 0;
			for (int i = 0; i < len; ++i) {
				printf("  %d\n", number[i] - '0');
				tmp = tmp * 10 + (number[i] - '0');
			}
			printf("cnt = %d: %lld\n", *runrunCnt, tmp);
		}
#endif

		if (*runrunCnt == K) {
			for (int i = 0; i < len; ++i) {
				ret = ret * 10 + (number[i] - '0');
			}
		}
	}
	else {
		//前の数値-1
		if (number[idx - 1] != '0') {
			number[idx] = number[idx - 1] - 1;
			ret = Hoge(runrunCnt, K, number, len, idx + 1);
			if (*runrunCnt == K) { return ret; }
		}

		number[idx] = number[idx - 1];
		ret = Hoge(runrunCnt, K, number, len, idx + 1);
		if (*runrunCnt == K) { return ret; }

		if (number[idx - 1] != '9') {
			number[idx] = number[idx - 1] + 1;
			ret = Hoge(runrunCnt, K, number, len, idx + 1);
			if (*runrunCnt == K) { return ret; }
		}
	}

	return ret;
}

int main()
{
	INT K;
	cin >> K;

	LLONG baseNo = 10;
	INT len = 2;

	//1桁
	if (K <= 9) {
		cout << K;
	}
	else {
		LLONG runrun = 0;
		INT runrunCnt = 9;

		while (1) {
			char number[256];
			sprintf(number, "%lld", baseNo);
			for (INT i = 1; i <= 9; ++i) {
				number[0] = '0' + i;
				runrun = Hoge(&runrunCnt, K, number, len, 1);

				if (runrunCnt == K) {
					break;
				}
			}

			if (runrunCnt == K) {
				break;
			}

			baseNo += 10;
			len += 1;
		}

		cout << runrun;
	}

	return 0;
}
#endif

Measured memory_bytes: 256
m,d=map(int,input().split())

ans=0
if d<10:
    print(0)
else:
    for i in range(10,d+1):
        for j in range(1,m+1):
            if (i%10)*(i//10)==j and i%10>=2 and (i//10)>1:
                ans+=1
    print(ans)


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

using namespace std;

// void print2DArray(vector<vector<int>> &mat) {
//   for (auto row : mat) {
//     for (auto elm : row)
//       cout << elm << " ";
//     cout << endl;
//   }
// }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, k, d, s, num_mischief = 0;
  cin >> n >> k;

  vector<bool> snuke(n);

  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> s;
      snuke[s - 1] = true;
    }
  }

  for (int i = 0; i < n; i++) {
    if (snuke[i] == false) {
      num_mischief++;
    }
  }

  cout << num_mischief << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 3652