akhauriyash/Code-Regression huggingface dataset:
x, y = list(map(int, input().split()))

count = 1
curr_num, next_num = x, x*2
multiplier = 2
while next_num <= y:
    if next_num%curr_num == 0:
        count += 1
        multiplier = 2
        curr_num = next_num
    else:
        multiplier += 1
    next_num = curr_num * multiplier

print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static int f(int n) {
		if (n % 2 == 0)
			return n / 2;
		else
			return 3 * n + 1;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		sc.close();
		int ans = 1, tmp = s, t = 4;
		if(s == 1 || s == 2) 
			t = s;
		
			while (tmp != t) {
				tmp = f(tmp);
				++ans;
			}
		ans += 3;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <list>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;

vi a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a)
    cin >> i;
}

void f(list<int>& a, int what) {
  a.push_front(what);
}

void g(list<int>& a, int what) {
  a.push_back(what);
}

void solve() {
  list<int> ans;

  auto b = vector({f, g});

  if (n % 2 == 0)
    swap(b[0], b[1]);

  for (int i = 0; i < n; ++i)
    b[i % 2](ans, a[i]);

  for (auto&& i : ans)
    cout << i << ' ';

  cout << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 4;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 10328
def main(s: str):
    l = len(s)

    i = 0
    ans = 0

    while i != (l // 2):
        if s[i] != s[(l - i) - 1]:
            ans += 1

        i += 1

    print(ans)


if __name__ == "__main__":
    s = input()

    main(s)


Measured memory_bytes: 2940
#include <cstdio>

using namespace std;

struct List {
    int* cnt[25];
};

int n, k;

char str[1100000];

int high_len;
int high_str;

void work(List& lst, int cur_len, int cur_str)
{
    List new_list;
    int lst_total = 0;
    for (int i = 0; i <= n - cur_len; i++) {
        for (int j = 0; j < (1 << i); j++) {
            lst_total += lst.cnt[i][j];
        }
    }
    if (lst_total < k) return;
    //printf("%d %d\n", cur_len, cur_str);
    if (cur_len > high_len || (cur_len == high_len && cur_str < high_str)) {
        high_len = cur_len; high_str = cur_str;
    }
    if (cur_len == n) return;
    for (int i = 0; i <= n - cur_len - 1; i++) {
        new_list.cnt[i] = new int[1 << i];
        for (int j = 0; j < (1 << i); j++) {
            new_list.cnt[i][j] = 0;
        }
    }
    for (int i = 0; i <= n - cur_len; i++) {
        for (int j = 0; j < (1 << i); j++) {
            if (!lst.cnt[i][j]) continue;
            for (int bt = i - 1; bt >= 0; bt--) {
                int bt_val = (j & (1 << bt)) ? 1 : 0;
                if (bt_val == 0) {
                    new_list.cnt[bt][j & ((1 << bt) - 1)] += lst.cnt[i][j]; break;
                }
            }
        }
    }
    work(new_list, cur_len + 1, cur_str * 2);
    for (int i = 0; i <= n - cur_len - 1; i++) {
        for (int j = 0; j < (1 << i); j++) {
            new_list.cnt[i][j] = 0;
        }
    }
    for (int i = 0; i <= n - cur_len; i++) {
        for (int j = 0; j < (1 << i); j++) {
            if (!lst.cnt[i][j]) continue;
            for (int bt = i - 1; bt >= 0; bt--) {
                int bt_val = (j & (1 << bt)) ? 1 : 0;
                if (bt_val == 1) {
                    new_list.cnt[bt][j & ((1 << bt) - 1)] += lst.cnt[i][j]; break;
                }
            }
        }
    }
    work(new_list, cur_len + 1, cur_str * 2 + 1);
    for (int i = 0; i <= n - cur_len - 1; i++) {
        delete[] new_list.cnt[i];
    }
}

int main()
{
    List x;
    scanf("%d%d", &n, &k);
    for (int i = 0; i <= n; i++) {
        x.cnt[i] = new int[1 << i];
        scanf("%s", str);
        for (int j = 0; j < (1 << i); j++) {
            x.cnt[i][j] = (str[j] == '1' ? 1 : 0);
        }
    }
    work(x, 0, 0);
    for (int i = high_len - 1; i >= 0; i--) {
        printf("%c", (high_str & (1 << i)) ? '1' : '0');
    }
    return 0;
}


Measured memory_bytes: 20472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}
int main(){
  int N,M;
  cin >>N>>M;
  vector<ll>X(M);
  rep(i,M){cin >>X[i];}
  sort(X.begin(),X.end());
  vector<ll>dist(M-1);
  rep(i,M-1){dist[i]=X[i+1]-X[i];}
  ll ans=0;
  sort(dist.begin(),dist.end());
   if(N<M){
  	rep(i,M-N){
       ans+=dist[i];
    }
  }
  cout<<ans;
}

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

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll r, g, b;
    r = count(S.begin(), S.end(), 'R');
    g = count(S.begin(), S.end(), 'G');
    b = count(S.begin(), S.end(), 'B');
    ll all = N * (N - 1) * (N - 2) / 6;
    ll ng = all - r * g * b;    
    for (int j = 0; j < N; j++) {
        for (int k = j + 2; k < N; k += 2) {
            if (S[j] == S[k]) continue;
            int i = (j + k) / 2;
            if (S[j] != S[i] && S[k] != S[i]) ng++;
        }
    }
    cout << all - ng << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,p;
	bool b=true;
	cin >> n >> p;
	vll a(n);
	rep(i,n){
		cin >> a[i];
		if(a[i]%2) b=false;
	}
	if(b){
		if(p==0) printf("%lld\n",(ll)pow(2,n));
		else cout << 0 << endl;
	}
	else printf("%lld\n",(ll)pow(2,n-1));
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

int main() {
	string n;
	cin >> n;

	int sum = 0;

	for (int i = 0; i < n.size(); i++)
	{
		sum += (int)(n[i] - '0');
	}

	if (stoi(n) % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	int A[100];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn bellman_ford(graph: &Vec<Vec<(usize, isize)>>, ln: &mut Vec<Option<isize>>) -> Vec<bool> {
    let mut inf = vec![false; graph.len()];
    for _ in 0..graph.len() {
        for v in 0..graph.len() {
            for e in &graph[v] {
                let cost = e.1;
                let to = e.0;
                let from = v;
                if let Some(x) = ln[from] {
                    if let None = ln[to] {
                        ln[to] = Some(x + cost);
                    } else if let Some(y) = ln[to] {
                        if y < x + cost {
                            inf[to] = true;
                            ln[to] = Some(x + cost);
                        }
                    }
                }
            }
        }
    }
    inf
}

fn main() {
    let (n, m, p): (usize, usize, isize);
    input!(n, m, p);

    let mut graph = vec![Vec::new(); n];
    let mut longest = vec![None; n];
    longest[0] = Some(0);

    for _ in 0..m {
        let (a, b, c): (usize, usize, isize);
        input!(a, b, c);
        graph[a - 1].push((b - 1, c - p));
    }

    bellman_ford(&graph, &mut longest);
    if bellman_ford(&graph, &mut longest)[n - 1] {
        println!("-1");
    } else {
        println!("{}", std::cmp::max(0, longest[n - 1].unwrap()));
    }
}


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

const int mod = 1e9 + 7;
const int inf = 999999;

int n, k[105], cou, ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		if (k[i] == 1)++cou;
	}
	if (cou == 0) { cout << "1" << endl; return 0; }
	if (cou == n) { cout << n + 1 << endl; return 0; }
	cou = 0;
	for (int i = 1; i < n; ++i) {
		if (k[i - 1] && k[i]) {
			++cou;
			ans = max(ans, cou);
		}
		else {
			ans = max(ans, cou);
			cou = 0;
		}
	}
	cout << ans + 2 << endl;
}



Measured memory_bytes: 3096
n, m, q = gets.chomp.split(" ").map(&:to_i)
input = []
ans = []
q.times do
    input << gets.chomp.split(" ").map(&:to_i)
end

[*1..m].repeated_combination(n) do |arr|
    sum = 0
    input.each do |a, b, c, d|
        if arr[b-1] - arr[a-1] == c then
            sum += d
        end
    end
    ans << sum
end

puts ans.max

Measured memory_bytes: 15636
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=9000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;cin>>n>>k;
    ll a[n+1];
    vector<pll> v;
    v.push_back({0,0});
    ll summ=0;
    ll ans=0;
    rep(i,1,n+1){
        cin>>a[i];
        summ+=a[i];
        ll t=summ-i*k;
        v.push_back({t,i});
    }
    sort(v.begin(),v.end());
    bitinit(n+1);
    ll num;
    rep(i,0,n+1){
        ll now=v[i].second;
        if(now==0){
            num=i;
            continue;
        }
        ll t=sum(now);
        ans+=t;
        add(now,1);
    }
    ans+=n-num;
    cout<<ans<<endl;
}




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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	int K;
	vec(A);
	cin >> K;
	fx(K) {
		vecp(A);
	}

	ll l = -1, r = LLONG_MAX - 1;
	while (r - l > 1) {
		ll mid = (l + r) / 2;
		ll m = mid;
		fx(K) {
			m = m / A[x] * A[x];
		}
		if (m >= 2) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	ll m = r;
	fx(K) {
		m = m / A[x] * A[x];
	}
	if (m != 2) {
		ce(-1);
		return 0;
	}
	ll ans1 = r;
	l = 0;
	r = LLONG_MAX - 1;

	while (r - l > 1) {
		ll mid = (l + r) / 2;
		ll m = mid;
		fx(K) {
			m = m / A[x] * A[x];
		}
		if (m > 2) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	m = l;
	fx(K) {
		m = m / A[x] * A[x];
	}
	if (m != 2||l<ans1) {
		ce(-1);
		return 0;
	}

	doublece(ans1, l)



    return 0;
}



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

using namespace std;

#define lint long long

int main(){
    int D;
    cin >> D;
    
    if(D == 25){
        cout << "Christmas" << endl;
    }
    if(D == 24){
        cout << "Christmas Eve" << endl;
    }
    if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    if(D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 2000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int N; cin >> N;
	map<string, int>mp;
	REP(i, N) {
		string S; cin >> S;
		mp[S]++;
	}
	int mx = 0;
	for (auto x : mp) {
		mx = max(mx, x.second);
	}
	vector<string>v;
	for (auto x : mp) {
		if (x.second == mx)v.push_back(x.first);
	}
	VSORT(v);
	REP(i, v.size()) {
		print(v[i]);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 25584
import math
n, h = map(int, input().split())
alst = []
blst = []
for _ in range(n):
  a, b = map(int, input().split())
  alst.append(a)
  blst.append(b)

ma = max(alst)
blst.sort(reverse=True)

ans = 0
for b in blst:
  if b < ma:
    break
  if h <= 0:
    break
  h -= b
  ans += 1

if h > 0:
  ans += math.ceil(h / ma)

print(ans)

Measured memory_bytes: 11316
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

int main(){
	int s,g,h;
	int a,b;
	
	while(cin>>a>>b,a||b){
		s=g=h=0;
		int t=b-a;
		while(t>=1000){
			t-=1000;
			s++;
		}
		while(t>=500){
			t-=500;
			g++;
		}
		while(t>=100){
			t-=100;
			h++;
		}
		cout<<h<<" "<<g<<" "<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
s[50],j,p,q;
main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(;j;)for(p=i++,j=0x199797,q=j%16;q>1;j/=16)for(q=j%16;q>2;)q-=s[p++];
}}

Measured memory_bytes: 532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,a;deque<int> d;bool r = false;cin >> n;
  while(cin >> a){
    r ^= 1;
    if(r) d.push_back(a);
    else d.push_front(a);
  }
  if(!r){
    for(i=0;i<n;i++) cout << d[i] << " ";
  } else {
    for(i=n-1;i>=0;i--) cout << d[i] << " ";
  }
  cout << endl;
}
  

Measured memory_bytes: 2944
n = int(input())
# else以下は10以上の時のみ適応できるので10未満は埋め込み
if n < 10:
    print(n)
else:
    # 説明中のiを求めるため10でわる(切り捨て)
    x = n // 10
    # 公式による計算。x^2+8
    basenum = x * x + 8
    addnum = 0
    # ここ以下で(10*i から n, 1 から n)と(1 から n, 10*i から n)の数え上げを行うが、
    # 重複した数え上げがないか確認するフラグ
    hassame = False
    # 数え上げ(ここでは、(10*i から n, 1 から n)だけ数え上げ、倍にすることで(1 から n, 10*i から n)分も数え上げる)
    for i in range(x * 10 + 1, n + 1):
        for j in range(1, n + 1):
            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
                addnum += 1
                if i == j:
                    hassame = True
    res = basenum + addnum * 2 # 10の倍数の公式分と　力わざで数え上げた加算
    res -= 1 if hassame else 0 # ダブルカウントがあれば1減らす
    print(res)


Measured memory_bytes: 41692
use std::cmp;

const N: usize = 5001;
const INF: usize = 1 << 50;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for c in 1..n {
        let p = sc.read::<usize>() - 1;
        graph[p].push(c);
    }
    let w: Vec<usize> = sc.vec(n);

    let (_, b) = dfs(0, &graph, &w);
    if b != INF {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}

fn dfs(v: usize, graph: &Vec<Vec<usize>>, w: &Vec<usize>) -> (usize, usize) {
    let mut cur = [INF; N];
    cur[0] = 0;
    for &next in graph[v].iter() {
        let (left, right) = dfs(next, graph, w);
        let mut next = [INF; N];
        for one in 0..N {
            if one + left < N {
                next[one + left] = cmp::min(next[one + left], cur[one] + right);
            }
            if one + right < N {
                next[one + right] = cmp::min(next[one + right], cur[one] + left);
            }
        }
        cur = next;
    }

    let w = w[v];
    let mut min = INF;
    for one in 0..N {
        let another = cur[one];
        if one <= w {
            min = cmp::min(another, min);
        }
        if another <= w {
            min = cmp::min(one, min);
        }
    }

    (w, min)
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 38012
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(in) in.begin(), in.end()

int main(){
    FIO;
    ll n;   cin >> n;
    string s;   cin >> s;
    ll ans = 0, dp[n];
    for(ll x = n-1 ; x >= 1 ; x--){
        for(ll i = 0 ; i < n ; i++){
            dp[i] = 0;
        }
        for(ll i = n-1 - x ; i >= 0 ; i--){
            if(s[i] == s[i+x]){
                dp[i] = (dp[i+1]+1 <= x) ? dp[i+1] + 1 : x;
            }else{
                dp[i] = 0;
            }
            ans = max(ans, dp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
X=int(input())
if(X%7==2):
  print("sat")
elif(X%7==3):
  print("sun")
elif(X%7==4):
  print("mon")
elif(X%7==5):
  print("tue")
elif(X%7==6):
  print("wed")
elif(X%7==0):
  print("thu")
else:
  print("fri")



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	vector<int> s(31);
  s={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << s[K-1] << endl;
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll k; cin>>k;
	if( ~k&1 || k%5==0 ){ cout<<-1; return 0; }
	ll g = 7;
	forn(i,k+1)
	{
		if(g%k==0){ cout<<i+1; return 0; }
		g = (g*10+7)%k;
	}
	cout<<-1;

	return 0;
}


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

using namespace std;
int n,i,j;
double dp0[6005];
double dp1[6005];
double ans,p;
int main()
{
    cin>>n;
    dp1[n]=1;
    for(i=1;i<=n;i++)
    {
        cin>>p;

        for(j=0;j<=2*n;j++)
        {
            dp0[j]=dp1[j];
            dp1[j]=0;
        }

        for(j=0;j<=2*n;j++)
        {
            if(j)
                dp1[j-1]+=dp0[j]*((double)1 - p);
            if(j<2*n)
                dp1[j+1]+=dp0[j]*p;
        }
    }

    for(i=n+1;i<=2*n;i++)
        ans+=dp1[i];

    cout.precision(12);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b < 0) No();
  else {
    ll l = 4 * a * b, r = (c - a - b) * (c - a - b);
    if (l < r) Yes();
    else No();
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define MEM(i,j) memset(i,j,sizeof i)
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bitset<100001> vis;
multiset<pll> s;
vector<pll> v;
pll arr[100001],tarr[100001];
ll w[100001],dp[100001];
vector<ll> child[100001];

void dfs(ll x)
{
	dp[x]=w[x]-1;
	for(ll i:child[x])
		dfs(i),dp[x]+=dp[i];
}

int main()
{jizz
	ll n,x,c=0,t;
	cin >> n;
	for(int i=1;i<=n;++i)
		cin >> x,s.insert(tarr[i]=arr[i]=MP(x,i)),w[i]=1;
	sort(tarr+1,tarr+n+1);
	for(int i=n;i>0;--i)
		if(!vis[tarr[i].S])
		{
			x=tarr[i].S;
			while(1)
			{
				//cout << x << " " << w[x] << " " << arr[x].F << " " << arr[x].F-n+w[x]*2 << "\n";
				auto p=s.lower_bound(MP(arr[x].F-n+w[x]*2,-1));
				if(p==s.end()||p->F!=arr[x].F-n+w[x]*2)
					break;
				//cout << x << " -> " << p->S << "*\n";
				s.erase(s.find(MP(arr[x].F,arr[x].S)));
				//cout << x << " -> " << p->S << "\n";
				vis[x]=1,v.pb(MP(x,p->S)),w[p->S]+=w[x],child[p->S].pb(x),x=p->S;
			}
		}
	if(vis.count()!=n-1) cout << "-1\n";
	else
	{
		for(int i=1;i<=n;++i)
			if(!vis[i]) x=i;
		dfs(x);
		if(dp[x]!=arr[x].F) cout << "-1\n";
		else 
			for(auto i:v)
				cout << i.F << " " << i.S << "\n";
	}
}

Measured memory_bytes: 17908
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
#define PI 3.14159265359
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
int x[200000], y[200000];
signed main() {
	int a;
	cin >> a;
	f(i, a) {
		cin >> x[i] >> y[i];
	}
	sort(x, x + a);
	sort(y, y + a);
	if (a % 2) {
		cout << y[a / 2] - x[a / 2] + 1 << endl;
	}
	else {
		cout << y[a / 2] + y[a / 2 - 1] - x[a / 2] - x[a / 2 - 1] + 1 << endl;
	}
}

Measured memory_bytes: 6696
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long long a,b,c;
	cin >> a >> b >> c; 
//	double aa = sqrt(a)+sqrt(b);
//	double bb = sqrt(c);
//	cout << aa << " " << bb << endl;
//	if(aa<bb) cout << "Yes" << endl;
//	else cout << "No" << endl;
//	cout << sqrt(1000000000);
	long long d = c - a - b;
	if(4*a*b<d*d&&d>0) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    static final long MOD=1000000007;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int m=scan.nextInt();
        long[][][]dp=new long[2][n][n];
        dp[0][0][0]=1;
        for(int i=0;i<m;++i){
            int u=i%2;
            for(int j=0;j<n;++j)Arrays.fill(dp[1-u][j],0);
            for(int j=0;j<n;++j)
                for(int k=0;k<n;++k){
                    if(j<n-1){
                        dp[1-u][j+1][k]+=dp[u][j][k];
                        dp[1-u][j+1][k]%=MOD;
                    }
                    dp[1-u][j][j]+=(k+1)*dp[u][j][k];
                    dp[1-u][j][j]%=MOD;
                    dp[1-u][j][k]+=(j-k)*dp[u][j][k];
                    dp[1-u][j][k]%=MOD;
                }
        }
        long t=0;
        for(int i=0;i<n;++i)
            t=(t+dp[m%2][i][n-1])%MOD;
        for(int i=1;i<=n-1;++i)
            t=t*i%MOD;
        System.out.println(t);
    }
}


Measured memory_bytes: 25516
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl

int main ()
{
    ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, i, in;
    long long sum = 0;
    cin >> n >> m;
    int a[n+1];
    priority_queue < int > pq;
    for(i = 1; i <= n; i++)
    {
        cin >> in;
        pq.push(in);
    }
    while(m > 0)
    {
        in = pq.top() / 2; pq.pop();
        m--;
        pq.push(in);
    }
    while(!pq.empty())
    {
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 1020
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    ll ans = 0;
    int height = 0;
    rep(i, N) {
        height = max(height, A[i]);
        ans += height - A[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  ll n,k,f=0;;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    a[i]=x;
    f+=x;
  }
  //cout<<f<<endl;
  ll p=f/n;
  ll xx=p+1,xt=0;
  f=0;
  for(int i=0;i<n;i++)
  {
  f+=((p-a[i])*(p-a[i]));
  }
 // cout<<f<<endl;
  for(int i=0;i<n;i++)
  {
  xt+=((xx-a[i])*(xx-a[i]));
  }
cout<<min(xt,f)<<endl;
  
  

}
return 0;
}


Measured memory_bytes: 256
a=list()
for i in range(5):
  a.append(int(input()))
k=int(input())
flag=True
for i in range(4):
  for j in range(i,5):
    if a[i]-a[j]>k or a[j]-a[i]>k:
      flag=False
if flag==True:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

const int M=200;

struct Node
{
	int num,cnt;
} s[M];

int n;
int cnt[M];
int ls;

void init()
{
	memset(cnt,0,sizeof(cnt));
	for(int i=2;i<=n;i++)
		cnt[i]=1;
}

void deal(int id)
{
	for(int i=2;i<id;i++)
		if(id%i==0)
			cnt[i]+=cnt[id],cnt[id/i]+=cnt[id],cnt[id]=0;
}

bool cmp(Node a,Node b)
{
	return a.cnt>b.cnt;
}

int solve_75()
{
	int ret=0;
	for(int i=0;i<ls;i++)
		if(s[i].cnt+1>=75)
			ret++;
	return ret;
}

int solve_15_5()
{
	int ret=0;
	int k1=0,k2=0;
	for(int i=0;i<ls;i++)
	{
		if(s[i].cnt+1>=15)
			k1++;
		if(s[i].cnt+1>=5)
			k2++;
	}
	ret=k1*(k2-1);
	return ret;
}

int solve_25_3()
{
	int ret=0;
	int k1=0,k2=0;
	for(int i=0;i<ls;i++)
	{
		if(s[i].cnt+1>=25)
			k1++;
		if(s[i].cnt+1>=3)
			k2++;
	}
	ret=k1*(k2-1);
	return ret;	
}

int solve_5_5_3()
{
	int ret=0;
	int k1=0,k2=0;
	for(int i=0;i<ls;i++)
	{
		if(s[i].cnt+1>=5)
			k1++;
		if(s[i].cnt+1>=3)
			k2++;
	}
	ret=k1*(k1-1)*(k2-2)/2;
	return ret;
}

void solve()
{
	ls=0;
	for(int i=2;i<=n;i++)
		if(cnt[i]!=0)
			s[ls].num=i,s[ls].cnt=cnt[i],ls++;
	sort(s,s+ls,cmp);
	int ans=solve_75()+solve_15_5()+solve_25_3()+solve_5_5_3();
	printf("%d\n",ans);
}

int main()
{
	scanf("%d",&n);
	init();
	for(int i=n;i>=2;i--)
		deal(i);
	solve();
	return 0;
}



Measured memory_bytes: 256
f=->n,m,a,b{s=a/m*n*~-n/2+b/m*n
b%=m
x=-b+m*y=(b+n*a%=m)/m
y>0&&s+=f[y,a,m,-x%a]+y*=n+-x/a
s}
gets
$<.map{p f[*_1.split.map(&:to_i)]}

Measured memory_bytes: 15120
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        double parcent=M;
        parcent =Math.pow(2, parcent);
        int i=(int)parcent;
        System.out.println(((N-M)*100+M*1900)*i);
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);

P dequeue(void);

int min(int,int);

int main(){
  int a = 0, c;
  int i, x;
  P u;
  scanf("%d %d", &n, &x);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head != tail){
    u=dequeue();
    c=min(x,u.t);
    u.t-=c;
    a+=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,a);
    }
  }
  return 0;
}
void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){return a<b ? a:b;}



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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
LL x[N], y[N], z[N];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i ++ ) cin >> x[i] >> y[i] >> z[i];
	
	LL res = 0;
	for (int i = 0; i < 1 << 3; i ++ )
	{
		vector<LL> t;
		for (int j = 0; j < n; j ++ )
		{
			LL sum = 0;
			if ((i >> 0) & 1) sum += x[j];
			else sum -= x[j];
			if ((i >> 1) & 1) sum += y[j];
			else sum -= y[j];
			if ((i >> 2) & 1) sum += z[j];
			else sum -= z[j];
			t.PB(sum);
		}
	
		sort(t.begin(), t.end());
		reverse(t.begin(), t.end());
		LL sum = 0;
		for (int j = 0; j < m; j ++ ) sum += t[j];
		res = max(res, sum);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
typedef long long ll;
using namespace std;

int main(void) {
    ll N;cin>>N;
    ll sum = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3192
OD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

N = int(input())
ans = 0
def dfs(i,before):
    global ans
    if all(before.count(i) > 0 for i in '357') and int(before) <= N:
        ans += 1
    if i == 10:
        return
    for s in '357':
        dfs(i + 1,before + s)
for s in '357':
    dfs(1,s)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    ll n,m,ans = 0;
    cin >> n >> m;
    vector<ll> a(n);
    priority_queue<ll> pq;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pq.push(a[i]);
    }
    while(m--){
        ll x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

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

class Dice{
public:
  int r[6];

  Dice(){}
  void roll(int i, int j, int k, int l){
    int t = r[i];
    r[i] = r[j];
    r[j] = r[k];
    r[k] = r[l];
    r[l] = t;
  }
  void roll_x(){roll(0, 1, 5, 4);} // to N
  void roll_y(){roll(0, 3, 5, 2);} // to E
  void roll_z(){roll(4, 2, 1, 3);}
  void move(char ch){
    if (ch == 'N') roll_x();
    if (ch == 'E') roll_y();
    if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    if (ch == 'W') for (int i = 0; i < 3; i++) roll_y();
  }
};

int getRight(Dice d, int top, int face){
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if(d.r[0] == top && d.r[1] == face) return d.r[2];
      d.roll_z();
    }
    if (i % 2 == 0) d.roll_y();
    else d.roll_x();
  }

}

int main(int argc, char const *argv[]) {
  Dice d;
  for (int i = 0; i < 6; i++) cin >> d.r[i];

  int q;
  cin >> q;

  int top, face;
  for (int i = 0; i < q; i++) {
    cin >> top >> face;
    cout << getRight(d, top, face) << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
while True:
    n=int(input())
    if n==0:
        break
    else:
        lst=[0]*10
        for i in range(n):
            lst[int(input())] += 1
        for i in range(10):
            if lst[i]==0:
                print('-')
            else:
                for j in range(lst[i]):
                    print('*', end='')
                print()


Measured memory_bytes: 7580
n = int(input())
l = [[0]*3 for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    l[i] = [a+b, a, b]
l.sort(reverse=True)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += l[i][1]
    else:
        ans -= l[i][2]
print(ans)

Measured memory_bytes: 25076
#include<bits/stdc++.h>
using namespace std;
const int N=100000+10;
int n;
struct dish{
	int x,y;
	bool operator < (const dish &rhs) const {
		return x+y>rhs.x+rhs.y;
	}
}a[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+n+1);
	
	long long ans=0;
	for (int i=1;i<=n;i++) {
		if (i%2) ans+=(long long)a[i].x;
			else ans-=(long long)a[i].y;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())

a=list(map(int,input().split()))

visited=[0]*n
if k<=n:
    now=0
    nex=0
    loop_start=0
    target=0

    for i in range(n):
        now=nex
        visited[now]+=1
        nex=a[now]-1
        if i+1==k:
            print(nex+1)
            exit()
now=0
nex=0
loop_start=0
target=0
lis=[]
s=set()
flag=False

for i in range(2*n):
    now=nex
    visited[now]+=1
    nex=a[now]-1
    if flag:
        if now+1 not in s:
           lis.append(now+1)
           s.add(now+1)
           continue
        else:
            break
    if visited[now]==2:
        loop_start=i
        target=now+1
        lis.append(now+1)
        s.add(now+1)
        flag=True


dif=len(lis)
first=loop_start-dif
k-=first
print(lis[k%dif])






Measured memory_bytes: 114864
#include <iostream>

int main() {
  std::pair<int, int> p1, p2, p3, p4;
  std::cin >> p1.first >> p1.second >> p2.first >> p2.second;

  int dx{p1.first-p2.first}, dy{p1.second-p2.second};
  p3.first = p2.first + dy;
  p3.second = p2.second - dx;
  p4.first = p3.first + dx;
  p4.second = p3.second + dy;
  printf("%d %d %d %d\n", p3.first, p3.second, p4.first, p4.second);
}

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

int main() {
  int i,n,y,x,s;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
  	cin>>a[i];

  x=a[0];
  s=a[0];
  
  for(i=1;i<n;i++)
  { 
    if(a[i]>x)
    {
		y=a[i]-x;
      s=s+y;
    } 
    x=a[i];
  }
  cout<<s;
  
  
  return 0;
}
  


Measured memory_bytes: 3588
n,k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

small = 0
while small < n and a[small] < k:
    small += 1
n = small


cnt = 0
able = [False for i in range(k)]
able[0] = True
min_need = n
max_able = 0
i = n-1
while i >= 0:
    if max_able + a[i] >= k:
        min_need = i
        for j in range(min_need):
            if max_able + a[j] >= k:
                min_need = i
                break
    for j in range(min(max_able, k-a[i]-1), -1, -1):
        if able[j]:
            able[j+a[i]] = True
            max_able = max(j+a[i], max_able)
    i -= 1
print(min_need)



Measured memory_bytes: 44432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b,k;
int main(void){
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }else if(a+b>=k){
        cout<<0<<" "<<b-(k-a)<<endl;
    }else{
        cout<<0<<" "<<0<<endl;
    }

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    pii a[n+5];
    for (int i=1;i<n;i++) cin >> a[i].fi >> a[i].se;
    int c[n+5];
    memset (c,0,sizeof(c));
    vector<int> v[n+5];
    for (int i=1;i<n;i++) {
        v[a[i].fi].pb(i);
        v[a[i].se].pb(i);
    }
    for (int i=1;i<=n;i++) {
        int p = 1;
        set<int> udah;
        vector<int> belum;
        for (int j=0;j<v[i].size();j++) {
            int x = v[i][j];
            if (c[x] != 0) {
                udah.insert(c[x]);
            } else {
                belum.pb(x);
            }
        }
        for (int j=0;j<belum.size();j++) {
            while (udah.find(p) != udah.end()) {
                p++;
            }
            c[belum[j]] = p;
            udah.insert(p);
            p++;
        }
    }
    int maxi=0;
    for (int i=1;i<n;i++) maxi = max(maxi, c[i]);
    cout << maxi << endl;
    for (int i=1;i<n;i++) cout << c[i] << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int N,W;
ll dp[101][100001]={};
int main(void){
    cin>>N>>W;
    int w[N],v[N];
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    for(int j=0;j<=W;j++){
        if(j>=w[0])dp[0][j]=v[0];
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j]=max(dp[i][j],dp[i-1][j]);
            }
        }
    }
    cout<<dp[N-1][W]<<endl;
   return 0;
}

Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int a = Integer.parseInt(scan.next());
	int b = Integer.parseInt(scan.next());
	int c = Integer.parseInt(scan.next());
	    
	int ab = a + b;
	int bc = b + c;
	int ca = c + a;

	System.out.println(min(ab, min(bc, ca)));
	scan.close();
    }

    public static int min(int x, int y) {
	return x < y ? x : y;
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

/**
 * @author ??\???
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int arg = scanner.nextInt();
		scanner.close();
		
		System.out.println((int)Math.pow(arg, 3));
	}

}

Measured memory_bytes: 26156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = long long;
using P = pair<int,int>;


int main(){
    int H,W;
    const int MAX_W = 200;
    while(cin >> H >> W, W != 0){
        int C = H*H + W*W;
        int minH = MAX_W, minW = MAX_W;
        int minC = minH*minH + minW*minW;
        for(int w = 1; w <= MAX_W; w++){
            for(int h = 1; h < w; h++){
                int c = w*w + h*h;
                if((c > C && minC >= c ) || (c == C && H < h)){
                    minH = h;
                    minW = w;
                    minC = c;
                }
            }
        }

        cout << minH << " " << minW << endl;
    }
}



Measured memory_bytes: 3096