akhauriyash/Code-Regression huggingface dataset:
#include <type_traits>
#include <initializer_list>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdint>
#include <iterator>
#include <iostream>
namespace loquat {
namespace bitmanip {
template <typename T>
inline auto clz(T x) noexcept ->
	typename std::enable_if<sizeof(int) < sizeof(T), unsigned int>::type
{
	return __builtin_clzll(x);
}
template <typename T>
inline T clp2(T x) noexcept {
	if(x == 0u){ return 0u; }
	return T(1u) << (sizeof(T) * 8u - clz(x - 1));
}
}
}
namespace loquat {
template <typename Behavior>
class segment_tree {
public:
	using behavior_type = Behavior;
	using value_type = typename behavior_type::value_type;
private:
	size_t m_actual_size;
	std::vector<value_type> m_values;
	behavior_type m_behavior;
	void initialize(){
		const auto m = m_values.size() / 2;
		for(size_t i = 0; i < m; ++i){
			const auto k = m - 1 - i;
			m_values[k] = m_behavior.merge(
				m_values[k * 2 + 1], m_values[k * 2 + 2]);
		}
	}
public:
	template <typename Iterator>
	segment_tree(
		Iterator first,
		Iterator last,
		const behavior_type& behavior = behavior_type())
		: m_actual_size(std::distance(first, last))
		, m_values(bitmanip::clp2(m_actual_size) * 2 - 1)
		, m_behavior(behavior)
	{
		const auto it = m_values.begin() + m_values.size() / 2;
		std::copy(first, last, it);
		initialize();
	}
	value_type query(size_t left, size_t right) const {
		const auto m = m_values.size() / 2;
		left += m; right += m;
		value_type l_value = m_behavior.identity(), r_value = l_value;
		while(left < right){
			if((left & 1u) == 0u){
				const auto& x = m_values[left];
				l_value = m_behavior.merge(l_value, x);
			}
			if((right & 1u) == 0u){
				const auto& x = m_values[right - 1];
				r_value = m_behavior.merge(x, r_value);
			}
			left  = left / 2;
			right = (right - 1) / 2;
		}
		return m_behavior.merge(l_value, r_value);
	}
};
template <typename Iterator, typename Behavior>
segment_tree<Behavior> make_segment_tree(
	Iterator first,
	Iterator last,
	Behavior&& behavior)
{
	return segment_tree<Behavior>(
		first, last, std::forward<Behavior>(behavior));
}
}
using namespace std;
struct range_query_behavior {
	using value_type = int;
	value_type identity() const { return 0; }
	value_type merge(const value_type& a, const value_type& b) const {
		return (a + b) % 3;
	}
};
int main(){
	ios_base::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	vector<int> is(s.size()), it(t.size());
	for(size_t i = 0; i < s.size(); ++i){ is[i] = (s[i] == 'A' ? 1 : 2); }
	for(size_t i = 0; i < t.size(); ++i){ it[i] = (t[i] == 'A' ? 1 : 2); }
	auto s_st = loquat::make_segment_tree(
		is.begin(), is.end(), range_query_behavior());
	auto t_st = loquat::make_segment_tree(
		it.begin(), it.end(), range_query_behavior());
	int q;
	cin >> q;
	while(q--){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a; --c;
		const bool answer = (s_st.query(a, b) == t_st.query(c, d));
		cout << (answer ? "YES" : "NO") << "\n";
	}
	return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

int main() {
	int n; cin >> n;
	vector<vector<pair<int, int>>> xy(n);
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y; cin >> x >> y; x--;
			xy.at(i).push_back(make_pair(x, y));
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		bitset<15> b(i);
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (b.test(j)) count++;
		}
		bool ok = true;
		for (int j = 0; j < n; j++) {
			if (!(b.test(j))) continue;
			for (auto p : xy.at(j)) {
				int z = p.first;
				if (b[z] != p.second) ok = false;
			}
			if (!ok) break;
		}
		if (ok) ans = max(ans, count);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  vector<int> v(n);
  rep(i, n) v[i] = i+1;
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  int cnt = 1;
  int pn = -1;
  int qn = -1;
  do {
    bool pok = true;
    bool qok = true;
    rep(i, n) {
      if (v[i] != p[i]) {
        pok = false;
      }
      if (v[i] != q[i]) {
        qok = false;
      }
    }
    if (pok) pn = cnt;
    if (qok) qn = cnt;
    cnt++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(pn - qn) << endl;
  return 0;
}

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

int n, p;
string s;
int a[200001];
int main() {
  cin >> n >> p >> s;
  
  if (p == 2) {
    long sum = 0;
    for (int i = 0; i < n; ++i) {
      if ((s[i] - '0') % 2 == 0) sum += i + 1;
    }
    cout << sum << endl;
    return 0;
  } else if (p == 5) {
    long sum = 0;
    for (int i = 0; i < n; ++i) {
      if ((s[i] - '0') % 5 == 0) sum += i + 1;
    }
    cout << sum << endl;
    return 0;
  }
  
  int sum = 0;
  int base = 1;
  for (int i = n - 1; i >= 0; --i) {
    sum += base * (s[i] - '0');
    sum %= p;
    a[i] = sum;
    base *= 10;
    base %= p;
  }
  
  map<int, int> mp;
  long ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans += mp[a[i]];
    ++mp[a[i]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int64_t modpow(int64_t x, int64_t r, int64_t mod) {
    if(r == 0) return 1;
    if(r % 2 == 1) return x * modpow(x, r - 1, mod) % mod;
    return modpow((x * x) % mod, r / 2, mod);
}

int64_t comb(int64_t n, int64_t r, int64_t mod) {
    int64_t numerator = 1,
            denominator = 1;
    for(int i = n - r + 1; i <= n; i++) numerator *= i, numerator %= mod;
    for(int i = 1; i <= r; i++) denominator *= i, denominator %= mod;
    denominator = modpow(denominator, mod - 2, mod);
    return numerator * denominator % mod;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod7) - 1 - comb(n, a, mod7) - comb(n, b, mod7);
    while(ans < 0) ans += mod7, ans %= mod7;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll K, N;
  std::cin >> K >> N;
  std::vector< ll > va(N+1, 0LL);
  std::vector< ll > vm(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }
  va[N] = K + va[0];
  for (ll i = 0; i < N; i++) {
    vm[i] = va[i+1] - va[i];
  }

  ll ans = K - *std::max_element(vm.begin(), vm.end());
  print(ans);

  return 0;
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define vre(x) reverse( x.begin() , x.end() ) ;
#define aso(x) sort( x , x + x.size() )
#define are(x) reverse( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h = 798568968205 ; srand(h) ;
    //int t ; cin >> t ; while(t--){}
    string s ; cin >> s ;
    if ( s[1] == 'B' ) cout << "ARC" ;
    else cout << "ABC" ;
    cout << "\n" ;
}

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

int main() {
  int N;
  scanf("%d", &N);
  int v[N];
  vector<int> A,B;
  int testa[100000];
  int testb[100000];
  for (int i = 0; i < 100001; ++i) testa[i] = 0;
  for (int i = 0; i < 100001; ++i) testb[i] = 0;
  
  for (int i = 0; i < N; ++i) {
    scanf("%d", &v[i]);
    if(i%2==0){
      A.push_back(v[i]);
      ++testa[v[i]];
    }
    else{
      B.push_back(v[i]);
      ++testb[v[i]];
    }
  }

  int maxa=v[0];
  int nexta=0;
  int maxb=v[1]; 
  int nextb = 0;
  for (int i = 0; i < 100001; ++i){
    if(testa[maxa]<=testa[i] && maxa!=i){
      nexta = maxa;
      maxa = i;
    }
    else if(testa[nexta]<testa[i] && maxa!=i){
      nexta = i;
    }
    if(testb[maxb]<=testb[i] && maxb!=i){
      nextb = maxb;
      maxb = i;
    }
    else if(testb[nextb]<testb[i] && maxa!=i){
      nextb = i;
    }
  }


  //cout << maxa << endl;
  //cout << maxb << endl;
  //cout << nexta << endl;
  //cout << nextb << endl;




  bool flip = true;
  int count = 0;
  int ans = 0;

  if(maxa==maxb){
    for (int i = 0; i < N; ++i){
      if(flip){
        if(v[i]!=nexta) ++count;
        flip = false;
      }
      else{
        if(v[i]!=maxb) ++count;
        flip = true;
      }
    }
    ans = count;
    count = 0;
    flip = true;
    for (int i = 0; i < N; ++i){
      if(flip){
        if(v[i]!=maxa) ++count;
        flip = false;
      }
      else{
        if(v[i]!=nextb) ++count;
        flip = true;
      }
    }
    if(count<ans) ans = count;
  }



  else{

  for (int i = 0; i < N; ++i){
    if(flip){
      if(v[i]!=maxa) ++ans;
      flip = false;
    }
    else{
      if(v[i]!=maxb) ++ans;
      flip = true;
    }
  }

  }

  cout << ans << endl;


}



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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    string s , t;
    cin >> s >> t;

    int n = s.length();
    int m = t.length();

    int ans = 1e9;
    for(int i = 0 ; i <= n - m ; i ++) {

            int cnt = 0;
            for(int j = i ; j < i + m ; j ++) {
                    if(s[j] != t[j - i]) cnt ++;
            }

            ans = min(ans , cnt);
    }

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

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 3720
use std::io::stdin;
use std::iter::Iterator;
use std::collections::VecDeque;
use std::collections::HashMap;

fn solve(cin: &mut ConsoleInputWrapper) {
    let a: i64 = cin.input().parse().unwrap();
    let b: i64 = cin.input().parse().unwrap();
    let gcd = gcd(a, b);
    let primes = factorization(gcd);
    println!("{}", primes.len() + 1);
    ()
}

//Other Functions Here

fn main() {
    let mut cin = ConsoleInputWrapper::new();
    solve(&mut cin);
}

fn factorization(value: i64) -> HashMap<i64, usize> {
    let sqrt = f64::sqrt(value.clone() as f64);
    let mut value = value;
    let mut map = HashMap::new();
    let mut p = 2;
    while p.clone() as f64 <= sqrt {
        let mut count = 0;
        while (value % p.clone()) == 0 {
            count += 1;
            value /= p.clone();
        }
        if count > 0 {
            map.insert(p.clone(), count);
        }
        p += 1;
    }
    if value != 1 {
        map.insert(value, 1);
    }
    map
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b.clone(), a % b)
    }
}

fn min(a: i32, b: i32) -> i32 {
    if a < b { a } else { b }
}

fn max(a: i32, b: i32) -> i32 {
    if a > b { a } else { b }
}

struct ConsoleInputWrapper {
    queue: VecDeque<String>
}

impl ConsoleInputWrapper {
    fn new() -> ConsoleInputWrapper {
        ConsoleInputWrapper {
            queue: VecDeque::new()
        }
    }
    fn input(&mut self) -> String {
        if self.queue.len() <= 0 {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let list: Vec<&str> = s.split_whitespace().collect();
            for string in list {
                self.queue.push_back(String::from(string));
            }
        }
        self.queue.pop_front().unwrap()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<P> p(N+1);
  vector<ll> v;
  ll i;
  
  priority_queue<P> q;
  for(i=0; i<N; i++) {
    ll x, h;
    cin >> x >> h;
    p[i].ft=x;
    p[i].sc=(h+A-1)/A;
  }
  p[N]=P(INF, INF);
  sort(p.begin(), p.end());
  
  vector<ll> x(N+1);
  vector<ll> h(N+1);
  for(i=0; i<=N; i++) {
    x[i]=p[i].ft;
    h[i]=p[i].sc;
  }
  
  ll cnt[MAX*2]={};
  ll ans=0;
  for(ll l=0; l<N; l++) {
    if(cnt[l]<h[l]) {
      ll r=upper_bound(x.begin(), x.end(), x[l]+D*2)-x.begin();
      
      ll dam=h[l]-cnt[l];
      ans+=dam;
      cnt[l]+=dam;
      cnt[r]-=dam;
    }
    
    cnt[l+1]+=cnt[l];
  }
  
  
  pt(ans);
  
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int kotae[100000] = {};
	int N = S.size();
	
	int k = 0;
	rep(i, N) {
		if (S[i] == 'R') {
			k++;
		}
		else {
			kotae[i - 1] += (k + 1) / 2;
			kotae[i] += k / 2;
			k = 0;
		}
	}
	k = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'L') {
			k++;
		}
		else {
			kotae[i + 1] += (k + 1) / 2;
			kotae[i] += k / 2;
			k = 0;
		}
	}

	rep(i, N) cosp(kotae[i]);

	Would you please return 0;
}

Measured memory_bytes: 1104
#include<stdio.h>
int main(){
    int a,b,c,X;
    scanf("%d %d %d",&a,&b,&c);

    if (a>b){
        X=a;
        a=b;
        b=X;
    }
    if (b>c){
        X=b;
        b=c;
        c=X;
    }
    if (a>b){
        X=a;
        a=b;
        b=X;
    }
    printf("%d %d %d\n",a,b,c);

    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int MOD = 1e9 + 9;
const int N = 5e3 + 44;
const int p = 31;
const int m = 1e9 + 9;
int preH[N];
string s;
int n;
void compute_hash(string const& s) {

   long long hash_value = 0;
   long long p_pow = 1;
   int indx = 0;
   for (char c : s) {
      hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
      p_pow = (p_pow * p) % m;
      preH[indx++] = hash_value;
   }
}

int power(int b, int p) {
   if (p == 0) return 1;
   int res = power(b, p / 2);
   res = 1LL * res * res % MOD;
   if (p & 1) {
      res = 1LL * b * res % MOD;
   }
   return res;
}

int modInv(int x) {
   return power(x, MOD - 2);
}

int mul(int a , int b , int m){
   return (1LL * (a % m) * (b % m)) % m;
}

int add(int a , int b , int m){
   return (1LL * (a % m) + (b % m)) % m;
}

long long get_hash(int l , int r){
   long long ret = (preH[r] - (l ? preH[l - 1] : 0) + MOD) % MOD;
   return mul(ret , modInv(power(p , l)) , MOD);
}

bool valid(int sz){
   map<int , bool> mp;
   for(int i = n - sz; i >= 0 ; --i){
      int cur = get_hash(i , i + sz - 1);
      mp[cur] = true;
      int j = i - sz;
      if(j < 0)return false;
      int nxt = get_hash(j , j + sz - 1);
      if(mp.count(nxt)){
         return true;
      }
   }
   return false;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n;
   cin >> s;
   compute_hash(s);
   int l = 1 , r = n , ans = 0;
   while (l <= r){
      int mid = (l + r) / 2;
      if(valid(mid)){
         ans = mid , l = mid + 1;
      }
      else{
         r = mid - 1;
      }
   }

   cout << ans << "\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n,k; cin >> n >> k;
    ll sq = sqrt(n);
    sq++;
    vvl dp(k+1,vl(sq+1,0));
    REP(i,1,sq+1) dp[0][i] = dp[0][i-1] + 1;
    REP(i,1,sq+1) dp[1][i] = dp[1][i-1] + n/i;
    REP(i,2,k+1){
        dp[i][sq] += dp[i-1][n/sq];
        dp[i][sq] %= mod;
        for(ll j=sq-1; j>0; j--){
            dp[i][j] = dp[i][j+1] + (n/j-n/(j+1))*dp[i-2][j];
            dp[i][j] %= mod;
        }
        rep(j,sq){
            dp[i][j+1] += dp[i][j];
            dp[i][j+1] %= mod;
        }
    }
    cout << dp[k][1] << endl;
}


Measured memory_bytes: 25600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	scanf("%d", &n);
	ll mx[100000], count[100000], t[100000], a[100000];
	for(int i=0; i<n; i++){
		scanf("%lld", &t[i]);
		if(i==0){
			mx[0]=t[0], count[0]=1;
			continue;
		}
		if(t[i]>t[i-1]){
			mx[i]=t[i];
			count[i]=1;
		}else{
			mx[i]=t[i];
			count[i]=mx[i];
		}
	}
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
	}
	ll ans=1;
	for(int i=n-1; i>=0; i--){
		if(i==n-1){
			if((count[n-1]==1 && mx[n-1]!=a[n-1]) || mx[n-1]<a[n-1]){
				printf("%d\n", 0);
				return 0;
			}
			count[n-1]=1;
			mx[n-1]=a[n-1];
			continue;
		}
		if(a[i]>a[i+1]){
			if((count[i]==1 && mx[i]!=a[i]) || mx[i]<a[i]){
				printf("%d\n", 0);
				return 0;
			}
			count[i]=1;
			mx[i]=a[i];
		}else{
			if(count[i]==1 && a[i]<mx[i]){
				printf("%d\n", 0);
				return 0;
			}
			if(count[i]==1) continue;
			mx[i]=min(a[i], mx[i]);
			count[i]=mx[i];
		}
		ans*=count[i];
		ans%=MOD;
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3328
object Main{
  def main(args: Array[String]){
   
      val input=io.Source.stdin.getLines().mkString("\n")
      println(solve(input).toString.trim());
    
  }


  def solve(input:String):Int ={
    val nums = input.split(" ").map(_ .toInt)
    val ret = if(nums(1) < nums(0)){
    	nums(0) * 2 - 1
    } else if (nums(1) > nums(0)){
    nums(1) * 2 -1
    }else {
    nums(1) * 2
    }
    ret
  }
}

Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  string s;
  cin >> s;

  if(s.at(1)=='B')  cout << "ARC" << endl;
  else              cout << "ABC" << endl;
  
  return 0;
}

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

int main(){

    string str;
    int n;//命令の数
    cin >> str >> n;

    string meirei;
    string print = "print";
    string reverse = "reverse";
    string replace = "replace";
    int a,b;

    for(int i=0; i<n; i++){
        cin >> meirei;

        if(meirei==print){
            cin >> a >> b;
            cout << str.substr(a,b-a+1) <<endl;

        } else if(meirei==reverse) {
            cin >> a >> b;
            string restr;
            for(int j=0; j<b-a+1; j++){
                restr[j] = str[b-j];
                
            }
            for(int k=0; k<b-a+1; k++){
                str[a+k] = restr[k];
            }

        } else if(meirei==replace) {
            cin >> a >> b ;
            string p;
            cin >> p;
            str.replace(a,b-a+1,p);

        }
    }
    return 0;
}


Measured memory_bytes: 3216
import math

A, B = map(int, input().split())

a = set(range(math.ceil(A/0.08), math.ceil((A+1)/0.08)))
b = set(range(math.ceil(B/0.1), math.ceil((B+1)/0.1)))

c = a & b

if c:
    print(min(c))
else:
    print(-1)

Measured memory_bytes: 3064
#include <cstdint>
#include <algorithm>
#include <iostream>
typedef int64_t i64;

static const auto NMAX = 2000;

static int N, X, A[NMAX];
static int B[NMAX];

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin >> N >> X;
	i64 ans = 0;
	for(auto i = 0; i < N; i++) {
		std::cin >> A[i];
		B[i] = A[i];
		ans += B[i];
	}
	for(auto j = 1; j < N; j++) {
		i64 tmp = 0;
		for(auto i = 0; i < N; i++) {
			auto k = i - j;
			if(k < 0) k += N;
			B[i] = std::min(B[i], A[k]);
			tmp += B[i];
		}
		ans = std::min(ans, (i64)X * j + tmp);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, K;
int a[5010];

bool dp[5010][5010]; //dp[i][j] := i番目までを考えて,合計がjの時があるなら1
bool solve(int idx){
	rep(i, 5010)rep(j, 5010) dp[i][j] = 0;
	dp[0][0] = 1;
	rep(i, N)rep(j, K + 1){
		if(dp[i][j] == 0) continue;
		dp[i + 1][j] = 1;
		if(i == idx) continue;
		if(j + a[i] > K) continue;
		dp[i + 1][j + a[i]] = 1;
	}
	reps(i, max(0, K - a[idx]), K){
		if(dp[N][i]) return true;
	}
	return false;
}

int main(void){
	cin >> N >> K;
	rep(i, N) cin >> a[i];
	sort(a, a + N);
	int l = -1, r = N;
	while(r - l > 1){
		int m = (l + r) / 2;
		// printf("m %d\n",m );
		if(!solve(m)) l = m;
		else r = m;
	}
	printf("%d\n", l + 1);
	return 0;
}

Measured memory_bytes: 24832
N = int(input())


def calculate(n):
    if n <= 599:
        print(8)
        return

    if n <= 799:
        print(7)
        return

    if n <= 999:
        print(6)
        return

    if n <= 1199:
        print(5)
        return

    if n <= 1399:
        print(4)
        return

    if n <= 1599:
        print(3)
        return

    if n <= 1799:
        print(2)
        return

    if n <= 1999:
        print(1)
        return

calculate(N)

Measured memory_bytes: 9192
n, m = map(int, input().split())
max_l = 0
min_r = 10**5
for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
res = min_r - max_l + 1
if res<0:
  res = 0
print(res)


Measured memory_bytes: 9088
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;

void dfs(int x,int y,int cou);
int n,m;
int mas[100][100]={{0}};
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
int ans = 0;

int main(){
	while(cin >> m >> n && n && m){
		for(int i=0;i<=n+1;i++){
			for(int j=0;j<=m+1;j++){
				if(i>=1 && j>=1 && i<=n && j<=m) cin >> mas[i][j];
				else mas[i][j] = 0;
			}
		}
		ans = 0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(mas[i][j]==1){
					dfs(j,i,0);
				}
				/*
				for(int k=0;k<n+2;k++){
					for(int l=0;l<m+2;l++){
						cout << mas[k][l] << " ";
					}
					cout << endl;
				}
				*/
			}
		}
		cout << ans << endl;
	}
}

void dfs(int x,int y,int cou){
	mas[y][x] = 0;
 	for(int i=0;i<4;i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(mas[ny][nx]==1){
			dfs(nx,ny,cou+1);
		}
	}
	mas[y][x] = 1;
	if(mas[y+1][x]==0 && mas[y-1][x]==0 && mas[y][x+1] == 0 && mas[y][x-1]==0){
		ans = max(ans,cou+1);
	}
 	return;
}

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

using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	bool ok = false;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if (i * (m - j) + j * (n - i) == k)
				ok = true;
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

string s;

signed main() {
    cin >> s;
    rep(i,3) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}





Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#define GEN 5
#define MOD 924844033
typedef long long ll;
inline int sum(int x, int y)
{
	x += y;
	return x >= MOD ? x - MOD : x;
}
inline int sub(int x, int y)
{
	x -= y;
	return x < 0 ? x + MOD : x;
}
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int alpha[2][800005], poly_rev[800005], poly_ntt_lst = -1;
inline void poly_ntt_init(int n)
{
	if (poly_ntt_lst == n)
		return;
	poly_ntt_lst = n;
	alpha[0][0] = alpha[1][0] = 1;
	alpha[0][1] = quick_pow(GEN, (MOD - 1) / n);
	alpha[1][1] = quick_pow(alpha[0][1], MOD - 2);
	for (int i = 2; i <= n; i++)
	{
		for (int x = 0; x < 2; x++)
			alpha[x][i] = (ll)alpha[x][i - 1] * alpha[x][1] % MOD;
	}
	for (int i = 1, j = n >> 1; i + 1 < n; i++)
	{
		poly_rev[i] = j;
		int k = n >> 1;
		while (j & k)
		{
			j ^= k;
			k >>= 1;
		}
		j |= k;
	}
}
inline void poly_ntt(int *arr, int n, bool flg)
{
	poly_ntt_init(n);
	for (int i = 1; i + 1 < n; i++)
	{
		if (i < poly_rev[i])
			std::swap(arr[i], arr[poly_rev[i]]);
	}
	for (int i = 1; i < n; i <<= 1)
	{
		for (int j = 0, off = n / (i << 1); j < n; j += i << 1)
		{
			for (int k = j, cur = 0; k < j + i; k++, cur += off)
			{
				int x = (ll)arr[k + i] * alpha[flg][cur] % MOD;
				arr[k + i] = sub(arr[k], x);
				arr[k] = sum(arr[k], x);
			}
		}
	}
	if (flg)
	{
		int x = quick_pow(n, MOD - 2);
		for (int i = 0; i < n; i++)
			arr[i] = (ll)arr[i] * x % MOD;
	}
}
inline void poly_mul(int *a, int *b, int n)
{
	int len = 1;
	while (len >> 1 <= n)
		len <<= 1;
	poly_ntt(a, len, false);
	poly_ntt(b, len, false);
	for (int i = 0; i < len; i++)
		a[i] = (ll)a[i] * b[i] % MOD;
	poly_ntt(a, len, true);
}
int lst[200005], to[400005], pre[400005], tot;
int sz[200005], coef[800005], func[800005];
inline void add_edge(int u, int v)
{
	to[tot] = v;
	pre[tot] = lst[u];
	lst[u] = tot++;
}
void dfs(int u, int fa = -1)
{
	sz[u] = 1;
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] == fa)
			continue;
		dfs(to[i], u);
		sz[u] += sz[to[i]];
	}
}
ll fact[200005], inv[200005];
int main()
{
	// freopen("AGC005-F.in", "r", stdin);
	memset(lst, -1, sizeof(lst));
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge(--u, --v);
		add_edge(v, u);
	}
	dfs(0);
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			coef[sz[i]]--;
			coef[n - sz[i]]--;
		}
		coef[n]++;
	}
	fact[0] = inv[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = quick_pow(fact[i], MOD - 2);
	}
	for (int i = 0; i <= n; i++)
	{
		coef[i] = (ll)(coef[i] + MOD) * fact[i] % MOD;
		func[i] = inv[n - i];
	}
	poly_mul(func, coef, n + 1);
	for (int i = 1; i <= n; i++)
		printf("%lld\n", (ll)func[i + n] * inv[i] % MOD);
	return 0;
}


Measured memory_bytes: 32512
n=gets.to_i
vs=gets.split.map(&:to_i)
ans=0
odds=[0]*100001
evens=[0]*100001

0.step(n-2,2) do |i|
  odds[vs[i]]+=1
  evens[vs[i+1]]+=1
end

o1=odds.index(odds.max)
e1=evens.index(evens.max)
omax=odds.max
emax=evens.max

if o1==e1
  odds[o1]=0
  evens[e1]=0
  if evens.max+omax>odds.max+emax
    emax=evens.max
  else
    omax=odds.max
  end
end
puts n-omax-emax


Measured memory_bytes: 9612
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void){
    
    int N,M;

    cin >> N >> M;
    int a[N];

    int tmp_a, tmp_b;
    for(int i=0;i<N;i++){
        a[i] = 0;
    }

    for(int i=0;i<M;i++){
        cin >> tmp_a >> tmp_b;
        a[tmp_a-1]++;
        a[tmp_b-1]++;
    }
    for(int i=0;i<N;i++){
        cout << a[i] << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long inf=1e16+7;
int n,maxW;
int w[101],v[101];
long long f[101][100001];
inline void Enter(){
    cin>>n>>maxW;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
}
inline void Solve(){
    for(int i=0;i<=n;i++) for(int j=0;j<=100000;j++) f[i][j]=inf;
    f[0][0]=0;
    for(int i=1;i<=n;i++) for(int j=0;j<=100000;j++){
        f[i][j]=f[i-1][j];
        if(j>=v[i]) f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
    }
    for(int j=100000;j>=0;j--) if(f[n][j]<=maxW){
        cout<<j;
        break;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    Enter();
    Solve();
    return 0;
}

Measured memory_bytes: 79232
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<vector>
#include<algorithm>
#define llong long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 1e5;
struct Element
{
	int id,dir; llong x,endpos;
} a[N+3];
vector<llong> endpos;
int n; llong m,l;

llong divup(llong x,llong y) {return (x+y-1)/y;}

int main()
{
	scanf("%d%lld%lld",&n,&l,&m);
	for(int i=0; i<n; i++)
	{
		scanf("%lld%d",&a[i].x,&a[i].dir); a[i].id = i;
		if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
		else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
	}
	sort(endpos.begin(),endpos.end());
	if(a[0].dir==1)
	{
		int k; for(k=endpos.size()-1; k>=0; k--) {if(endpos[k]==a[0].endpos) break;}
		llong tot = 0ll;
		for(int i=1; i<n; i++)
		{
			if(a[i].dir==2)
			{
				llong dist = a[i].x-a[0].x;
				llong cnt = (2ll*m-dist+l)/l;
				tot += cnt;
			}
		}
//		printf("tot=%lld k=%d\n",tot,k);
		int sid = ((k-tot)%n+n)%n;
		for(int j=sid; j<sid+n; j++)
		{
			printf("%lld\n",endpos[j%n]);
		}
	}
	else if(a[0].dir==2)
	{
		int k; for(k=0; k<endpos.size(); k++) {if(endpos[k]==a[0].endpos) break;}
		llong tot = 0ll;
		for(int i=1; i<n; i++)
		{
			if(a[i].dir==1)
			{
				llong dist = a[0].x-a[i].x+l;
				llong cnt = (2ll*m-dist+l)/l;
				tot += cnt;
			}
		}
//		printf("tot=%lld k=%d\n",tot,k);
		int sid = ((k+tot)%n+n)%n;
		for(int j=sid; j<sid+n; j++)
		{
			printf("%lld\n",endpos[j%n]);
		}
	}
	return 0;
}
/*
5 20 17
3 1
4 1
5 1
18 2
19 1
*/
/*
5 20 5
5 2
6 1
7 1
18 2
19 1
*/

Measured memory_bytes: 4468
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [u32; n],
    }
    let mut ans = String::new();
    let mut stack = vec![];
    let mut now = 0;
    for p in p {
        while now < p {
            now += 1;
            stack.push(now);
            ans.push('(');
        }
        if stack.is_empty() || *stack.last().unwrap() != p {
            println!(":(");
            return;
        }
        ans.push(')');
        stack.pop();
    }
    println!("{}", ans);
}

fn main() {
    run();
}



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

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

        String[] in = br.readLine().split(" ");
        int r = Integer.parseInt(in[0]);
        int d = Integer.parseInt(in[1]);
        int x = Integer.parseInt(in[2]);

        for(int i = 0; i < 10; i++) {
            x = r * x - d;
            System.out.println(x);
        }

        br.close();
    }
}

Measured memory_bytes: 21972
n, f  = input().split(' ')
flavors =  []
for i in range(int(n)):
    flavors.append(i + int(f))

#print(flavors)

min_v = abs(flavors[0])
for i in flavors:
    if abs(i) < abs(min_v):
        min_v = i
      #  print(min_v)

print(sum(flavors) - min_v)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int a[100][100], b[100], n, m;
int main() {
	cin >> n >> m;
	rep(i,n) {
		rep(j,m) {
			cin >> a[i][j];
		}
	}
	rep(i,m) {
		cin >> b[i];
	}
	rep(i,n) {
		int ret = 0;
		rep(j,m) {
			ret += a[i][j] * b[j];
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double money=0.0;
  double M;
  string S;
  for(int i=0;i<n;i++){
    cin>>M>>S;
    if(S=="JPY"){
     money+=M; 
    }else{
     money+=M*380000; 
    }
  }
  cout<<fixed<<money<<endl;
}

Measured memory_bytes: 764
N = int(input())
arr = list(map(int, input().split()))

maxv = max(arr)
half = maxv/2
mindelta = float('inf')
ans = None
for i in range(N):
  if arr[i] == maxv:
    continue
  delta = abs(arr[i] - half)
  if delta < mindelta:
    mindelta = delta
    ans = arr[i]
print(maxv, ans)

Measured memory_bytes: 14060
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


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


def main():
    N = int(input().strip())
    if N == 1:
        return 0
    factors = factorization(N)
    ans = 0
    for factor in factors:
        counter = 1
        while True:
            if factor[1] >= counter:
                factor[1] -= counter
                counter += 1
                ans += 1
            else:
                break
    return ans


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
const int LEN5 = 1e5+5;
typedef long long ll;
int n,W,w[105],v[105]; ll dp[105][LEN5];
int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL);
   scanf("%d%d",&n,&W);
   for(int i =1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);

   for(int i = 1;i<=n;i++) {
      for(int k = 1;k<=W;k++) {
         if(k - w[i] >= 0) {
            dp[i][k-w[i]] = max(dp[i][k-w[i]],dp[i-1][k] + v[i]);
         }
         dp[i][k] = max(dp[i][k],dp[i-1][k]);
      }
   }
   ll ans = 0;
   for(int i =0;i<=W;i++) {
      ans = max(dp[n][i],ans);
   }
   cout<<ans<<endl;
}   

Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
int main(void){
    int k, x;
    cin >> k >> x;
    if(500*k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        int count = 0;
        while(a >= b) {
            b *= 2;
            count++;
            if(count > k) {
                System.out.println("No");
                return;
            }
        }

        while(b >= c){
            c *= 2;
            count++;
            if(count > k) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


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

int main(){
    string s; cin >> s; int cnt0=0, cnt1=0; 
    for(int i = 0; i < s.length(); i++){
        if(s[i]=='0') cnt0++;
        else cnt1++;
    }
    cout << 2 * min(cnt0, cnt1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int n;
long long int a=1,b=1,ratio_a,ratio_b,temp;

int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lld%lld",&ratio_a,&ratio_b);
        temp=max(a/ratio_a,b/ratio_b);
        while(temp*ratio_a<a||temp*ratio_b<b)
        {
            temp++;
        }
        a=temp*ratio_a;
        b=temp*ratio_b;
    }
    printf("%lld",a+b);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;


int main(){
    long n,m;
    cin >> n >> m;
    map<long,long> AC;
    map<long,long> WA;
    long seikai=0;
    long pena=0;
    
    for(int i=1;i<=m;i++){
        long a;
        string b;
        cin >> a >> b;
        if(b=="AC") AC[a]=i;
        else{
            if(AC[a]!=0) continue; //既にAC
            else{
                WA[a]++;
            }
        }
    }
    for(auto itr = AC.begin(); itr != AC.end() ; ++itr){
        if(itr->second !=0) seikai++;
    }
    for (auto itr=WA.begin();itr!=WA.end();itr++){
        if(AC[itr->first]!=0) pena+=itr->second;
    }
    cout << seikai << " " << pena << endl;
}




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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int q; cin >> q;
    deque<int> deq;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            int d; cin >> d;
            if(d == 0){
                int x; cin >> x;
                deq.push_front(x);
            }else if(d == 1){
                int x; cin >> x;
                deq.push_back(x);
            }
        }else if(query == 1){
            int p; cin >> p;
            cout << deq[p] << endl;
        }else if(query == 2){
            int d; cin >> d;
            if(d == 0) deq.pop_front();
            else deq.pop_back();
        }
    }
}


Measured memory_bytes: 4680
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;

// 誤差を加味した符号判定
int sign(double a){
  if(a > EPS) return +1;
  if(a < -EPS) return -1;
  return 0;
}

// 誤差を加味した同一判定
bool equal(double a, double b){ 
  return abs(b - a) < EPS;
}
bool operator==(const Point& a, const Point& b){
  return equal(a.real(), b.real()) && equal(a.imag(), b.imag());
}

// 比較演算子
namespace std{
  bool operator < (const Point& a, const Point& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

// 内積・外積
double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

// 点の回転
Point rotate(Point a, double b){
  return a * polar(1.0, b);
}

// 点の進行方向
int ccw(Point a, Point b, Point c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1; // 反時計回り
  if (cross(b, c) < -EPS)   return -1; // 時計回り
  if (dot(b, c) < 0)     return +2; // c--a--b の順番で一直線上
  if (norm(b) < norm(c)) return -2; // a--b--c の順番で一直線上
  return 0;                         // a--c--b の順番で一直線上(またはb == c)
}
typedef vector<Point> Polygon;

// Polygonの要素へのアクセス
Point curr(const Polygon& a, int x){ return a[x]; }
Point next(const Polygon& a, int x){ return a[(x + 1) % a.size()]; }
Point prev(const Polygon& a, int x){ return a[(x - 1 + a.size()) % a.size()]; }

// 点が多角形のどこにあるのか判定する
enum { OUT, ON, IN };
int contains(const Polygon& P, const Point& p){
  // 点pから半直線をひき、辺と交差する回数を数える
  bool in = false;
  REP(i, P.size()){
    Point a = curr(P, i) - p;
    Point b = next(P, i) - p;
    if(a.imag() > b.imag()) swap(a, b);
    // aからbの直線がy=0と交わり、その交点は原点の右側である
    if(a.imag() <= 0 && 0 < b.imag() && cross(a, b) < 0){ 
      in = !in;
    }
    if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

// 多角形の面積
double area(const Polygon& P) {
  double A = 0;
  REP(i, P.size()){
    A += cross(curr(P, i), next(P, i));
  }
  return A / 2.0;
}
int main(){
  while(true){
    Polygon t;
    REP(i, 3){
      double x, y;
      cin >> x >> y;
      t.push_back(Point(x, y));
    }
    if(cin.eof()) break;
    if(ccw(t[0], t[1], t[2]) == -1) swap(t[1], t[2]);
    double x, y; cin >> x >> y;
    if(contains(t, Point(x, y)) == IN) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u == NIL)return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u == NIL)return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u == NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(){
	int i, v, l, r, root;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		T[i].p = NIL;
	}
	
	for(i = 0; i < n; i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l = l;
		T[v].r = r;
		if(l != NIL) T[l].p = v;
		if(r != NIL) T[r].p = v;
	}
	
	for(i = 0; i < n; i++)if(T[i].p == NIL) root = i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x;
int main() {
    cin>>x;

    ll cnt=0;
    double sum=100;
    while(sum<x){
        sum+=(ll)(0.01*sum);
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3624