akhauriyash/Code-Regression huggingface dataset:
// 基本のinclude
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

int main() {
    double n, x, t;
    cin >> n >> x >> t;
    double a = n / x;
    cout << int(ceil(a) * t) << endl;
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();

    	int sum=0;

    	List<Integer> data=new ArrayList<Integer>();

    	int result=1;

    	data.add(result);

    	while(true) {

    		if(N>=result*9) {
    			result*=9;
    			data.add(result);
    		}else {
    			break;
    		}

    	}

    	result=1;

    	while(true) {

    		if(N>=result*6) {
    			result*=6;
    			data.add(result);
    		}else {
    			break;
    		}

    	}

    	Collections.sort(data);



    	int[] dp=new int[N+1];

    	Arrays.fill(dp,99999999);
    	dp[0]=0;

    	for(Integer I:data) {
    		for(int j=0;j<=N;j++) {

    			if(j-I>=0) {
    				dp[j]=Math.min(dp[j],dp[j-I]+1);
    			}
    		}
    	}


    	System.out.println(dp[N]);


    }


}



Measured memory_bytes: 23892
def selectionSort(A):
    n = len(A)
    cnt = 0
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[minj] > A[j]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            cnt += 1
    print(*A)
    print(cnt)

n = int(input())
A = list(map(int, input().split(" ")))
selectionSort(A)


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

int main(void){
  int n; cin >> n;
  int x, count = 0;
  for(int i=0; i<n; i++){
    cin >> x;
    if(x != i+1) count++;
    if(count > 2) break;
  }
  if(count > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}


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

int main(){
  int k,n,a[100000],count = 0, result = 0;
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  int min = *min_element(a, a+n);
  for(int i = 0; i < n; ++i){
    if(a[i] == min) continue;
    else{
      count++;
      if(count >= k - 1){
        result++;
        count = 0;
      }
    }
  }
  if(count != 0) result++;
  cout << result << endl;
  return 0;
}


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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(void)
{
    int N, M;
    cin >> N >> M;

    int K, L;
    vector<int> *lang = new vector<int>[M];
    UnionFind u(N);

    for (int i = 0; i < N; i++) {
        cin >> K;

        for (int j = 0; j < K; j++) {
            cin >> L;
            lang[L - 1].push_back(i);

            u.unionSet(lang[L - 1][0], i);
        }
    }

    delete[] lang;

    for (int i = 1; i < N; i++) {
        if (!u.findSet(0, i)) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef pair<long, long> P;

int main(){
    int n; long W; cin >> n >> W;
    long v[n], w[n]; rep(i, n) cin >> v[i] >> w[i];
    vector<P> s1((int)(pow(2, n/2))), s2((int)(pow(2, n-n/2)));
    rep(i, pow(2, n/2)){
        P t = P(0, 0);
        rep(j, n/2)if((i>>j)&1) t.first += w[j], t.second += v[j];
        s1[i] = t;
    }
    rep(i, pow(2, n-n/2)){
        P t = P(0, 0);
        rep(j, n-n/2)if((i>>j)&1) t.first += w[n/2+j], t.second += v[n/2+j];
        s2[i] = t;
    }
    sort(s1.begin(), s1.end(), [](const P &a, const P &b){ if(a.first==b.first){return a.second > b.second;} else return a.first < b.first;});
    long cur1 = s1[0].first; long cur2 = s1[0].second;
    cur1 = cur2 = 0;
    rep(i, pow(2, n/2)){
        if(cur1<=s1[i].first && cur2>=s1[i].second) s1[i].first = cur1, s1[i].second = cur2; 
        cur1 = s1[i].first; cur2 = s1[i].second;
    }
    s1.push_back(P(-(1e17), 0)); s1.push_back(P(W+1, 0));
    sort(s1.begin(), s1.end(), [](const P &a, const P &b){ if(a.first==b.first){return a.second > b.second;} else return a.first < b.first;});
    long ans = 0;
    rep(i, pow(2, n-n/2)){
        int ok = 0; int ng = (int)(pow(2, n/2)) + 1;
        while(ng - ok > 1){
            int mid = (ok + ng) / 2;
            if(s1[mid].first+s2[i].first <= W) ok = mid;
            else ng = mid;
        }
        if(ok != 0) ans = max(ans, s1[ok].second + s2[i].second);
    }
    cout << ans << endl;
}


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

int main() {
  // 入力
  int n, m;
  cin >> n >> m;
  vector<int> v[m];
  for (int i = 0; i < m; i++) {
    int k, a;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> a;
      v[i].push_back(a - 1);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];

  // bit全探索する
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {  // 全てのパターンについて
    bool res = true;
    for (int k = 0; k < m; k++) {  // 全ての電球について
      int s = 0;
      for (auto x : v[k])
        if ((1 << x) & i) s++;
      if (s % 2 != p[k]) res = false;
    }
    if (res) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
input = gets.chomp
price = input.split(" ")[0].to_i

hated_numbers = gets.chomp.split(" ")

def isPermited?(price, hated_numbers)
  isPermited = true

  hated_numbers.each { |v| isPermited = false if price.to_s.include?(v) }

  isPermited
end

while !isPermited?(price, hated_numbers)
  price = price + 1
end

puts price


Measured memory_bytes: 1788
import math
args = [int(input()) for i in range(3)]
# 行と列どちら基準で塗るか　0→列，1→行
draw_flag = 0
if args[0] < args[1]:
    print(math.ceil(args[2] / args[1]))
else:
    print(math.ceil(args[2] / args[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int l[11];
  int mx = 0;
  int sum = 0;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> l[i];
    sum += l[i];
    mx = max(mx, l[i]);
  }
  
  if(sum > mx * 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	for ( int i = 1; ; i++ ) {
		int x;
		cin >> x;

		if ( x == 0 )
			break;

		cout << "Case " << i << ": " << x << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

struct Team {
    int id,time,score;
    int p[100];

    void addscore() {
        score++;
    }

    bool operator<(const Team &t) const {
        if(score == t.score) {
            if(time == t.time)  {
                return id < t.id;
            }
            return time > t.time;
        }
        return score < t.score;
    }
};

int main() {
    int M,T,P,R;
    while(cin >> M >> T >> P >> R) {
        if(M == 0 && T ==  0 && P == 0 && R == 0) break;

        vector<Team> v;
        rep(i,T) {
            Team team;
            team.id = i;
            team.score = 0;
            team.time = 0;
            memset(team.p,0,sizeof(team.p));
            v.push_back(team);
        }

        rep(i,R) {
            int m,t,p,j;
            cin >> m >> t >> p >> j;
            
            t--;
            p--;

            if(j == 0) {
                v[t].addscore();
                v[t].time += m + v[t].p[p] * 20;
            }
            else {
                v[t].p[p]++;
            }
        }

        sort(v.begin(),v.end());
        
        // cout << "--------- id output -------==" << endl;
        // REP(i,1,T) {
        //     int id = T-i;
        //     int id2 = T-i-1;
        //
        //     cout << id2 << " " << id << endl;
        // }

        cout << v[T-1].id+1;
        REP(i,1,T) {
            int id = T-i;
            int id2 = T-i-1;
            if(v[id2].score == v[id].score && v[id2].time == v[id].time) {
                cout << "=";
            }
            else cout << ",";

            cout << v[T-1-i].id+1;
        }

        cout << endl;
        
    }
    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll K,A,B; cin>>K>>A>>B;
  reps(i,A,B+1){
    if(i%K==0){
      cout<<"OK"<<endl;return 0;
    }
  }
  cout<<"NG"<<endl;

  return 0;
}


Measured memory_bytes: 3648
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}

use std::collections::HashMap;

fn main() {
    input!(s: Chars);
    input!(t: Chars);
    let n = s.len();
    let m = t.len();
    let mut hash: HashMap<char, Vec<usize>> = HashMap::new();
    for (i, &c) in s.iter().enumerate() {
        let v = hash.entry(c).or_insert_with(|| vec![]);
        v.push(i);
    }
    for (i, &c) in s.iter().enumerate() {
        let v = hash.entry(c).or_insert_with(|| vec![]);
        v.push(n + i);
    }

    //println!("{:?}", hash);
    let mut ans = 0;
    let mut p = 0;
    for &c in &t {
        if let Some(v) = hash.get(&c) {
            p = match v.binary_search(&p) {
                Ok(j) => v[j] + 1,
                Err(j) => v[j] + 1,
            };
            //println!("{}", p);
            if p >= n {
                p -= n;
                ans += n;
            }
        } else {
            println!("{}", -1);
            return;
        }
    }
    ans += p;
    println!("{}", ans);
}


Measured memory_bytes: 5092
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string youbi[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(1){
		int m,d,s=0;
		cin >> m >> d;
		if(!m&&!d)	break;
		for(int i=0;i<m-1;i++)	s+=days[i];
		s+=d;
		cout << youbi[(s-1)%7] << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=1010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int n,a[Maxn],ans[Maxn],la,nxt[Maxn];
int main()
{
	memset(nxt,-1,sizeof(nxt));
	n=read();
	bool flag=false;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(a[i]>0)flag=true;
	}
	if(!flag)
	{
		int mx=-inf,pos;
		for(int i=1;i<=n;i++)
		if(a[i]>mx)mx=a[i],pos=i;
		printf("%d\n%d\n",mx,n-1);
		for(int i=1;i<pos;i++)puts("1");
		int rest=n-pos+1;
		while(rest>1)printf("%d\n",rest--);
		return 0;
	}
	int l=1,r=n;la=0;
	while(a[r]<=0)ans[++la]=r--;
	while(a[l]<=0)ans[++la]=1,l++;
	n=r-l+1;
	for(int i=1;i<=n;i++)a[i]=a[i+l-1];
	LL s0=0,s1=0;int p0=-1,p1=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=0)continue;
		if(i&1)
		{
			s1+=(LL)a[i];
			if(p1!=-1)nxt[p1]=i;
			p1=i;
		}
		else
		{
			s0+=(LL)a[i];
			if(p0!=-1)nxt[p0]=i;
			p0=i;
		}
	}
	if(s1>s0)
	{
		printf("%lld\n",s1);
		int rest=n;
		for(int i=1;i<=n;i++)
		if(!(i&1)||a[i]<=0)ans[++la]=1,rest--;
		else break;	
		for(int i=1;i<=n;i+=2)
		{
			if(a[i]<=0)continue;
			if(nxt[i]!=-1)
			{
				int t=nxt[i]-i-1,u=1+(t+1)/2;
				for(int j=1;j<=(t+1)/2;j++)ans[++la]=u--;
				rest-=(nxt[i]-i);
			}
			else
			{
				while(rest>1)ans[++la]=rest--;
				printf("%d\n",la);
				for(int j=1;j<=la;j++)printf("%d\n",ans[j]);
				return 0;
			}
		}
	}
	else
	{
		printf("%lld\n",s0);
		int rest=n;
		for(int i=1;i<=n;i++)
		if(i&1||a[i]<=0)ans[++la]=1,rest--;
		else break;
		for(int i=2;i<=n;i+=2)
		{
			if(a[i]<=0)continue;
			if(nxt[i]!=-1)
			{
				int t=nxt[i]-i-1,u=1+(t+1)/2;
				for(int j=1;j<=(t+1)/2;j++)ans[++la]=u--;
				rest-=(nxt[i]-i);
			}
			else
			{
				while(rest>1)ans[++la]=rest--;
				printf("%d\n",la);
				for(int j=1;j<=la;j++)printf("%d\n",ans[j]);
				return 0;
			}
		}
	}
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

ll zat(ll a,ll b){
  if(a>=b) return a-b;
 else  return b-a;
  
}


int main(){
    ll x; cin>>x;
    ll sum=100;
    ll ans=0;
    while(sum<x){
      sum=sum+sum*0.01;
      ans++;
    }
    
  cout<<ans<<endl;  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 500005;

ll pos[MAX_N];
ll mn[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,D,q;
    cin >> n >> D;
    vi d(n);
    pos[0] = D;
    rep(i,n){
        cin >> d[i];
        pos[i+1] = min(pos[i],abs(pos[i]-d[i]));
    }
    mn[n] = 1;
    rrep(i,n){
        if(2*mn[i+1] <= d[i]){
            mn[i] = mn[i+1];
        }else{
            mn[i] = mn[i+1]+d[i];
        }
    }
    cin >> q;
    rep(i,q){
        int u;
        cin >> u;
        if(pos[u-1] >= mn[u]){
            cout << "YES\n";
        }else{
            cout << "NO\n";
        }
    }
    return 0;
}


Measured memory_bytes: 11776
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define DEBUG

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define ALL(v) v.begin(), v.end()

int main(){
    ll N;
    cin>>N;
    map<string,int> t{};
    REP(i,N){
        string n;
        cin>>n;
        t.insert(pair(n,0));
    }
    cout<<t.size();
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 19216
local par={}
local rank={}
local size={}

local function init(n)
    for i=1,n do
        par[i]=i
        rank[i]=1
        size[i]=1
    end
end

local function root(x)
    return par[x]==x and x or root(par[x])
end

local function same(x,y)
    return root(x)==root(y)
end

local function unite(x,y)
    x=root(x)
    y=root(y)
    if x==y then
        return
    end
    if rank[x]>rank[y] then
        par[x]=y
        size[y]=size[y]+size[x]
    else
        par[x]=y
        size[y]=size[y]+size[x]
        if rank[x]==rank[y] then
            rank[y]=rank[y]+1
        end
    end
end

local function getsize(x)
    return size[root(x)]
end

----------

local n,m=io.read("n","n")
local a,b={},{}
for i=1,m do
    a[i],b[i]=io.read("n","n")
end

local counter=0
for i=1,m do
    init(n)
    for j=1,m do
        if i~=j then
            unite(a[j],b[j])
        end
    end
    if not same(a[i],b[i]) then
        counter=counter+1
    end
end
print(counter)

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


int main() {
    int N,M;
    cin >> N >> M;
    vector<int> WA(N,0);
    vector<bool> AC(N,false);
    rep(i,M){
        int P;
        string S;
        cin >> P >> S;
        P--;
        if(!AC[P]){
            if(S == "AC"){
                AC[P] = true;
            }else{
                WA[P]++;
            }
        }
    }
    int wasum = 0;
    int acsum = 0;
    rep(i,N){
        if(AC[i]){
            acsum++;
            wasum += WA[i];
        }
    }
    cout << acsum << " " << wasum << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
typedef long long ll;
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

double a, b, x;
double pi = 3.141592653589793238;
double theta;

int main() {
    cin >> a >> b >> x;
    if (x < a * a * b / 2.0) {
        theta = atan(a * b * b / (2.0 * x));
    } else {
        double p = b / a;
        double q = x / (a * a * a);
        theta = atan(2.0 * (p - q));
    }
    theta = theta * 180.0 / pi;
    cout << fixed << setprecision(16) << theta << endl;
}


Measured memory_bytes: 512
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 10234567890000000
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 55
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next, a, b; }e[maxn << 2];
	il void add(int u, int v, int a, int b) { e[++ cnt] = (edge){v, head[u], a, b}, head[u] = cnt; }
}
using namespace Graph;
int n, m, dp[maxn][5005], s, c[maxn], d[maxn], vis[maxn][5005];
struct node {
	int u, v;
};
queue<node>q;
signed main() {
	n = read(), m = read(), s = min(read(), 5000ll);
	rep(i, 1, m) {
		int u = read(), v = read(), a = read(), b = read();
		add(u, v, a, b), add(v, u, a, b);
	}
	mem(dp, 63), dp[1][s] = 0;
	rep(i, 1, n) c[i] = min(2500ll, read()), d[i] = read();
	q.push((node){1, s});
	while(!q.empty()) {
		int u = q.front().u, l = q.front().v; q.pop(), vis[u][l] = 0;
		Next(i, u) {
			int v = e[i].v;
			if(l >= e[i].a && dp[u][l] + e[i].b < dp[v][l - e[i].a]) {
				dp[v][l - e[i].a] = dp[u][l] + e[i].b;
				if(vis[v][l - e[i].a] == 0) q.push((node){v, l - e[i].a}), vis[v][l - e[i].a] = 1;
			}
		}
		int tim = dp[u][l];
		l += c[u], tim += d[u];
		while(l <= 5000) {
			if(tim < dp[u][l]) {
				dp[u][l] = tim;
				if(vis[u][l] == 0) q.push((node){u, l}), vis[u][l] = 1;
			}
			l += c[u], tim += d[u];
		}
	}
	rep(i, 2, n) {
		int ans = inf;
		rep(j, 0, 5000) ans = min(ans, dp[i][j]);
		printf("%lld\n", ans);
	} 
	return 0;
}



Measured memory_bytes: 10464
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

    if ((N * A) < B) {
      System.out.println((N * A));
    } else {
      System.out.println(B);
    }

  }
}

Measured memory_bytes: 23252
k = input()
d = int(input())
MOD = 10**9 + 7

# dp[i][is_smaller][summation % d]
dp = [[[0]*d for i in range(2)] for i in range(len(k)+1)]
dp[0][0][0] = 1

for i in range(len(k)):
    # is_smaller = 0 -> is_smaller = 0
    for l in range(d):
        dp[i+1][0][(l+int(k[i])) % d] += dp[i][0][l]
        dp[i+1][0][(l+int(k[i])) % d] %= MOD
        
    # is_smaller = 0 -> is_smaller = 1
    for l in range(d):
        for j in range(int(k[i])):
            dp[i+1][1][(l+j) % d] += dp[i][0][l]            
            dp[i+1][1][(l+j) % d] %= MOD    

    # is_smaller = 1 -> is_smaller = 1
    for l in range(d):
        for j in range(10):
            dp[i+1][1][(l+j) % d] += dp[i][1][l]
            dp[i+1][1][(l+j) % d] %= MOD

print((dp[len(k)][1][0] + dp[len(k)][0][0] - 1) % MOD)

Measured memory_bytes: 64220
#include<iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    
    sort(d.begin(),d.end());
    d.erase(unique(d.begin(),d.end()),d.end());

    cout<<d.size()<<endl;
}

Measured memory_bytes: 256
a, b, c = gets.strip.split.map(&:to_i)
if a > b
  tmp = a
  a = b
  b = tmp
end
if a > c
  tmp = a
  a = c
  c = tmp
end
if b > c
  tmp = b
  b = c
  c = tmp;
end
puts (b-a)+(c-b)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> tree(100010);
vector<int> dp(100010, -1); // dp[頂点] = その頂点を始点とするLongest Pathの長さ
/*
全頂点についてメモ化BFSをする
*/
void dfs (int now){
  if(dp[now] != -1) return;
  int ret = -1;
  for(int to:tree[now]){
    if(dp[to] == -1) dfs(to);
    ret = max(ret, dp[to]);
  }
  dp[now] = ret + 1;
  return;
}
int main(){
  int n, m;
  cin >> n >> m;
  for(int i=0; i<m; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    tree[x].emplace_back(y);
  }
  for(int i=0; i<n; i++) dfs(i);
  cout << *max_element(dp.begin(), dp.end()) <<endl;
}

Measured memory_bytes: 11868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char ans;cin>>ans;ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
N=int(input())
if N==1:
  print(0)
  exit()
a=[0]*N
for i in range(N):
  m=int(input())
  a[m-1]=i
ans=0
for i in range(N):
  if i==0:
    s,l=-1,1
  elif i==N-1:
    if s<a[i]:
      l+=1
      ans=max(ans,l)
    else:
      ans=max(ans,l)
      l=1
  else:
    if s<a[i]:
      l+=1
    else:
      ans=max(ans,l)
      l=1
  s=a[i]
print(N-ans)
  

Measured memory_bytes: 47696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1000000007;

int main() {
  string s;
  cin >> s;
  set<char> a;
  for(int i=0; i<s.size(); i++) {
    a.insert(s[i]);
  }
  if(s.size()<26) {
    for(char i='a'; i<='z'; i++) {
      if(!a.count(i)) {
        cout << s << i << endl;
        return 0;
      }
    }
  } else {
    set<char> b;
    for(int i=s.size(); i>=0; i--) {
      for(char c=s[i]; c<='z'; c++) {
        if(b.count(c)) {
          cout << s.substr(0,i) << c << endl;
          return 0;
        }
      }
      b.insert(s[i]);
    }
    cout << -1 << endl;
    return 0;
  }
}


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

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

  int a, b;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(i) == 'A') {
      a = i;
      break;
    }
  }
  
  for(int i = 0; i < S.size(); i++) {
    if(S.at(S.size() - 1 - i) == 'Z') {
      b = S.size() - 1 - i;
      break;
    }
  }
  cout << b - a + 1 << endl;
  
  
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n>0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-1; j++) {
            cin >> a[i][j]; a[i][j]--;
        }
    }
    vector<pair<int, int>> v[n][n];
    int cnt[n][n];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-2; j++) {
            pair<int, int> s = {min(i, a[i][j]), max(i, a[i][j])};
            pair<int, int> t = {min(i, a[i][j+1]), max(i, a[i][j+1])};
            v[s.first][s.second].emplace_back(t);
            cnt[t.first][t.second]++;
        }
    }
    queue<pair<int, int>> q;
    queue<pair<int, int>> sw;
    for (int i = 0; i < n; i++) {
        pair<int, int> s = {min(i, a[i][0]), max(i, a[i][0])};
        if (cnt[s.first][s.second] == 0) q.push(s), cnt[s.first][s.second]++;
    }
    int t = 0; int l = 0;
    while (!q.empty()) {
        l++;
        while (!q.empty()) {
            t++;
            auto p = q.front(); q.pop();
            for (auto &e: v[p.first][p.second]) {
                cnt[e.first][e.second]--;
                if (cnt[e.first][e.second] == 0) sw.push(e);
            }
        }
        swap(sw, q);
    }
    if (t == n * (n-1) / 2) cout << l << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 47104
import numpy as np
n = int(input())
a = list(map(int, input().split()))
g = np.gcd.reduce(a)

if g > 1:
    print("not coprime")
    exit()

c = [0]*(10**6 + 1)

for i in a:
    c[i] += 1

for i in range(2, 10**6 + 1):
    if sum(c[i::i]) > 1:
        print("setwise coprime")
        exit()

print("pairwise coprime")

Measured memory_bytes: 150752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>ans(N);
    vector<ll>A(N);
    rep(i,N)cin>>A[i];
    reverse(all(A));
    rep(i,N){
        if(i%2==0){
            ans[i/2]=A[i];
        }else{
            ans[N-(i+1)/2]=A[i];
        }
    }
    rep(i,N){
        cout<<ans[i]<<" ";
    }
    cout<< endl;


    return 0;
    

}

Measured memory_bytes: 6292
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		int x, i = 0, j;
		ArrayList<Integer> t = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(i < 10000){
			x = sc.nextInt();
			if(x == 0)
				break;
			t.add(new Integer(x));
			i++;
		}
		j = i;
		for(i = 1; i - 1 != j; i++){
			System.out.println("Case " + i + ":" + " " + t.get(new Integer(i - 1)));
		}
		
	}
}

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

using namespace std;

int main(){
    int a, b;
    cin >>  a >> b;
    int res = 0;
    if(a > b){
        res = a;
        a-=1;
    }else{
        res = b;
        b-=1;
    }

    if(a>b){
        cout << res + a << endl;
    }else{
        cout << res + b << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        int n = Integer.parseInt(values[0]);
        line = scanner.nextLine();
        values = line.split(" ");
        int min = 100;
        int max = 0;
        ArrayList<Integer> vil = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            int c = Integer.parseInt(values[i]);
            if (min > c) {
                min = c;
            }
            if (max < c) {
                max = c;
            }
            vil.add(c);
        }
        long lowestHealth = 9223372036854775807L;
        long temp = 0;
        for (int i = 0; i < max - min; i++) {
            for (Integer integer : vil) {
                temp += Math.pow(integer - i,2);
            }
            if (lowestHealth > temp) {
                lowestHealth = temp;
            }
            temp = 0;
        }
        if (lowestHealth == 9223372036854775807L) {
            System.out.println(0);
        } else {
            System.out.println(lowestHealth);
        }
    }
}

Measured memory_bytes: 23764
s = input()
left = []
right = []
if len(s)%2 == 0:
    left = s[:len(s)//2]
    right = s[len(s)//2:]
else:
    left = s[:(len(s)-1)//2]
    right = s[(len(s)+1)//2:]

ans = 0
for l, r in zip(left, reversed(right)):
    if l != r:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

# Sieve of Eratosthenes
def is_prime(n):
    a = [None] * n
    non_prime_set = set()
    prime_set = set()
    a[0] = 0
    a[1] = 0
    for i in range(2, n):
        if i not in non_prime_set:
            prime_set.add(i)
            a[i] = 1
            for j in range(i*i, n, i):
                non_prime_set.add(j)
                a[j] = 0
    return(a)

def main():
    Q = int(input())
    L = [None] * Q
    R = [None] * Q
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    # 2017-like
    MAX = 101010
    prime_list = is_prime(MAX)
    a = [0] * MAX
    for i in range(1, MAX, 2):
        if (prime_list[i] and prime_list[(i+1)//2]):
            a[i] = 1

    s = [0] * (MAX+1)
    for i in range(MAX):
        s[i+1] = s[i] + a[i]

    for i in range(Q):
        print(s[R[i]+1] - s[L[i]])

if __name__ == '__main__':
    main()



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int x, a; cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<ll> A=vecin<ll>(N);
	vector<ll> B(N),C(N);

	map<ll,ll> MB,MC;
	REP(i,N){
		//if(A[i]>=N) continue;
		B[i] = i-A[i];
		C[i] = A[i]+i;
		MB[B[i]]++;
		MC[C[i]]++;
	}

	ll sum=0;
	for(auto& x:MB){
		ll V=x.first;
		sum += x.second * MC[V];
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 42104
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const double eps = 1e-10;
int dcmp(double x) { if(fabs(x) < eps) return 0; else return x<0?-1:1; }
const int N = 5e5+5;

int a[N];

int main() {
    int n;
    scanf("%d", &n);
    int l = 2e5+6, r = 2e5+5;
    for(int i = 0; i < n; i++) {
        if(i & 1) scanf("%d", &a[++r]);
        else scanf("%d", &a[--l]);
    }
    if(!(n&1)) for(int i = r; i >= l; i--) printf("%d%c", a[i], i==l?'\n':' ');
    else for(int i = l; i <= r; i++) printf("%d%c", a[i], i==r?'\n':' ');
    return 0;
}


Measured memory_bytes: 2944
<?php

$n = trim(fgets(STDIN));

$ans=[];

for($i=0; $i<strlen($n); $i++){
  if ($n[$i] == 'B'){
    if (count($ans) > 0){
      array_splice($ans,-1,1);
    }
  } else {
    array_push($ans,$n[$i]);
  }
}

for($i=0; $i<count($ans); $i++){
  echo $ans[$i];
}         

?>

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n; cin>>n;
    string s1, s2; cin>>s1>>s2;
    int ns1=s1.size();

    vector<int> a;
    int i=0;
    while(i<n){
        if(s1[i] == s1[i+1]){
            a.emplace_back(2);
            i+=2;
        }
        else{
            a.emplace_back(1);
            i++;
        }
    }

    int na=a.size();

    ll ans=1;
    for(int i=0; i<na; i++){
        if(i == 0){
            if(a[i] == 1) ans*=3;
            else ans*=6;
        }
        else{
            if(a[i-1] == 1) ans*=2;
            else{
                if(a[i] == 2) ans*=3; 
            }
        }
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>

int main(){
    using namespace std;
    constexpr unsigned long shosubu = 200;
    constexpr unsigned long tore = 10000000;
    using bigint = boost::multiprecision::cpp_int;
    bigint p10{string(shosubu, '9')}, eps{p10 / tore};
    ++p10;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> t(N);
    for(auto& i : t)cin >> i.first >> i.second;
    const auto& norm = [](const pair<long, long>& x, const pair<long, long>& y) -> unsigned long {
        unsigned long xd{static_cast<unsigned long>(max(x.first, y.first) - min(x.first, y.first))}, yd{static_cast<unsigned long>(max(x.second, y.second) - min(x.second, y.second))};
        return xd * xd + yd * yd;
    };
    bigint ans_lower{0}, ans_upper{0};
    for(const auto& i : t)for(const auto& j : t){
        bigint t{p10 * p10 * norm(i, j)};
        bigint c{boost::multiprecision::sqrt(t)}, d{c * c == t ? c : c + 1};
        ans_lower += c;
        ans_upper += d;
    }
    const auto& println_bigint_as_decimal = [](const bigint& x) -> void {
        string s = x.str();
        copy(s.begin(), s.end() - shosubu, ostream_iterator<char>(cout));
        cout << '.';
        copy(s.end() - shosubu, s.end(), ostream_iterator<char>(cout));
        cout << endl;
    };
    //println_bigint_as_decimal(max<bigint>(ans_lower / N + eps, ans_lower * (tore + 1) / (N * tore)));
    println_bigint_as_decimal(min<bigint>((ans_upper + N - 1) / N - eps, (ans_upper * (tore - 1) + N * tore - 1) / (N * tore)));
    return 0;
}

Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000007;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}

const int N = 2 * 100000;
ll dp[N];
ll last[N+1];
int cnt[N+1];
ll solve(const vector<int> &in){
  const int n = in.size();
  fill(cnt, cnt+N+1, 0);

  dp[0] = 1;
  cnt[in[0]] = 1;
  last[in[0]] = dp[0];
  REP(i,1,n){
    dp[i] = modadd(dp[i-1], last[in[i]]);
    cnt[in[i]]++;
    last[in[i]] = dp[i];
  }
  return dp[n-1];
}

 
int main(){
  int n;
  cin >> n;
  vector<int> a;
  int last = -1;
  rep(i,n){
    int tmp;
    cin>>tmp;
    if (tmp != last)a.emplace_back(tmp);
    last = tmp;
  }
  cout << solve(a) << endl;
}
 
 


Measured memory_bytes: 5108
s=input()
a=int(s)
sum=0
for i in range(2**(len(s)-1)):
  bi=list(map(int,str(format(i,"b").zfill(len(s)-1))))
  #print(bi)
  k=0
  for j in range(len(bi)):
    if bi[j]==1:
      
      sum+=int(s[k:j+1])
      #print(bi)
      #print(int(s[k:j+1]))
      k=j+1
  #print(int(s[k:]))
  #print(bi)
  sum+=int(s[k:])
    
print(sum)

Measured memory_bytes: 3064
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = Long.parseLong(sc.next());
    long R = 0;
    if(N%2==0){
      long subN = N/2;
      boolean escape = false;
      for(int i = 1;!escape;i++){
        if(subN/5!=0){
          R+=subN/5;
          subN=subN/5;
        }else{
          escape = true;
        }
      }
    }
    System.out.println(R);
  }
}

Measured memory_bytes: 35540
N,Y = map(int,input().split())
for i in range(N+1):
    if (Y - 1000*N -9000*i) % 4000 == 0:
        b = (Y - 1000*N -9000*i) // 4000 
        c = N - i - b
        if b >= 0 and c >= 0:
            print(i,b,c)
            exit()
print("-1 -1 -1")

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

int main()
{
	int a[3];
	for(int i =0; i < 3; ++i)
		cin >> a[i];

	sort(a, a + 3);

	int ans = a[0] + a[1];
	cout << ans << endl;

	return 0;
}


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

int main(){

    string S;
    cin >> S;

    if ( S == "AAA" || S == "BBB" ){
        cout << "No" << endl;
        return 0;
    }
    else{
        cout << "Yes" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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 dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vll h(n);
  rep(i,n) cin>>h[i];
  vvll t(n,vll(0));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  ll ans=0;
  rep(i,n){
    bool ok=true;
    for(auto p:t[i]){
      if(h[i]<=h[p]) ok=false;
    }
    if(ok) ans++;
  }
  COUT(ans);
}

Measured memory_bytes: 9784
import sys


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


def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = [0] + a
    B = [0] * (N + 1)

    for i in range(N, 0, -1):
        j = 2
        count = 0
        while i * j <= N:
            count += B[i * j]
            j += 1
        if (count + A[i]) % 2 == 0:
            pass
        else:
            B[i] = 1
    print(sum(B))

    for i in range(len(B)):
        if B[i]==1:
            print(i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 97584
n,i,j,a[2][3];long dp[25000005];long solve(int n,int u,int v){for(i=n;~i;--i)dp[i]=i;for(i=1;i<=n;++i)for(j=0;j<3;++j)if(a[v][j]>a[u][j]&&i>=a[u][j])dp[i]=fmax(dp[i],dp[i-a[u][j]]+a[v][j]);return dp[n];}main(){for(i=scanf("%d",&n)&0;i<2;i++)for(j=0;j<3;j++)scanf("%d",a[i]+j);printf("%lld\n",solve(solve(n,0,1),1,0));}

Measured memory_bytes: 195456