akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int N, T;
  cin >> N >> T;

  vector<int> t(N);
  rep(i, N) cin >> t[i+1];

  int ans = T;
  for (int i = 1; i <= N; ++i) {
    int d = t[i] - t[i - 1];
    if (d < T)
      ans += d;
    else
      ans += T;
  }

  cout << ans << endl;
}


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

int main(){
	int n,m1,m2;
	int *a,*b;
	int cnt=0,cs=1;
	bool flag[10][10][10]={false};
	char anim[10][10][10]={'0'};

	while(cin>>n,n){
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<5;k++){
					cin>>anim[i][j][k];
					if(anim[i][j][k]=='1') flag[i][j][k]=true;
					else flag[i][j][k]=false;
				}
			}
		}

		cin>>m1;
		a=new int[m1];
		for(int i=0;i<m1;i++) cin>>a[i];
		sort(a,a+m1);

		cin>>m2;
		b=new int[m2];
		for(int i=0;i<m2;i++) cin>>b[i];
		sort(b,b+m2);
		
		for(int day=0;day<n;day++){
			for(int i=0;i<5;i++){
				for(int j=0;j<5;j++){
					for(int k=0;k<5;k++){
						cnt=0;
						for(int p=i-1;p<=i+1;p++){
							for(int q=j-1;q<=j+1;q++){
								for(int r=k-1;r<=k+1;r++){
									if((p!=i || q!=j || r!=k) && anim[p][q][r]=='1') cnt++;
								}
							}
						}
						
						if(anim[i][j][k]=='1' && !binary_search(b,b+m2,cnt)) flag[i][j][k]=false;
						else if(anim[i][j][k]=='0' && binary_search(a,a+m1,cnt)) flag[i][j][k]=true;
					}
				}
			}
			
			for(int i=0;i<5;i++){ 
				for(int j=0;j<5;j++){ 
					for(int k=0;k<5;k++){
						if(flag[i][j][k]) anim[i][j][k]='1';
						else anim[i][j][k]='0';
					}
				}
			}
		}
		if(cs!=1) cout<<"\n";
		cout<<"Case "<<cs++<<":"<<"\n";
		
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<5;k++){
					cout<<anim[i][j][k];
				}
				cout<<"\n";
			}
			if(i!=4) cout<<"\n";
		}
		delete[] a,b;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int main(){
  int n,m;
  cin >> n >> m;
  int a[m];
  int ok[m];
  int max = 0;
  rep(i,m){
    int tmp,tmp2;
    cin >> tmp >> tmp2 ;
    if(tmp >= tmp2){
      ok[i] = 0;
    } else {
      ok[i] = n - tmp;
      if(ok[i] > max) max = ok[i];
    }
  }
  int sm = 0;
  rep(i,m){
    if(ok[i] != max) sm += ok[i];
  }
  cout << sm << endl;
}


Measured memory_bytes: 3088
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i * 500 + j * 100 + k * 50 == x:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
 
int main()
{
	string s;
    cin >> s;
    int t = s.size();
    while(t > 1){
        t -= 2;
        if(s.substr(0, t/2) == s.substr(t/2, t/2)) break;
    }
    cout << t << endl;


	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

ll solve(int n, vector<int> const & a, vector<char> const & op) {
    constexpr int M = 3;
    array<ll, M> cur, prv;
    fill(ALL(cur), LLONG_MIN);
    cur[0] = a[0];
    REP3 (i, 1, n) {
        swap(cur, prv);
        fill(ALL(cur), LLONG_MIN);
        auto sign = [&](int j) { return (j % 2 == 0 ? +1 : -1); };
        if (op[i - 1] == '+') {
            REP (j, M) {
                if (prv[j] != LLONG_MIN) {
                    chmax(cur[j], prv[j] + sign(j) * a[i]);   // ... + a_i
                }
                if (j + 1 < M and prv[j + 1] != LLONG_MIN) {
                    chmax(cur[j], prv[j + 1] + sign(j) * a[i]);  // ...) + a_i
                }
            }
        } else if (op[i - 1] == '-') {
            REP (j, M) {
                if (j >= 1 and prv[j] != LLONG_MIN) {
                    chmax(cur[j], prv[j] + sign(j) * a[i]);  // ...) - (a_i
                }
                if (j - 1 >= 0 and prv[j - 1] != LLONG_MIN) {
                    chmax(cur[j], prv[j - 1] + sign(j) * a[i]);  // ... - (a_i
                }
            }
        } else {
            assert (false);
        }
    }
    return *max_element(ALL(cur));  // ... )))
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<char> op(n - 1);
    REP (i, n - 1) {
        cin >> a[i] >> op[i];
    }
    cin >> a[n - 1];
    cout << solve(n, a, op) << endl;
    return 0;
}


Measured memory_bytes: 768
s=input()
K=int(input())

a=set()
for x in "abcdefghijklmnopqrstuvwxyz":
    for i in range(len(s)):
        if s[i]==x:
            for j in range(K):
                if i+j+1>len(s): break
                a.add(s[i:i+j+1])
         

    if len(a)>=K: break

a=sorted(list(a))
print(a[K-1])


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> ii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

int n, k, c;
string s;

void solve() {
	s = " " + s;
	int L[n + 2], R[n + 2];
	zero(L); zero(R);
	auto w{1}, i{1};
	while (i <= n) {
		if (w > k) break;
		if (s[i] == 'o') {
			L[w] = i;
			++w;
			i += c + 1;
		} else ++i;
	}
	w = k;
	i = n;
	while (i >= 1) {
		if (w < 1) break;
		if (s[i] == 'o') {
			R[w] = i;
			--w;
			i -= c + 1;
		} else --i;
	}
	repa(j, 1, k) {
		if (L[j] == R[j]) { 
			cout << L[j] << "\n";
		}
	}
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k >> c;
	cin >> s;
	solve();
	return 0;
}


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

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> favarite(M + 1);
    fill(favarite.begin(), favarite.end(), 0);
    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            int index;
            cin >> index;
            favarite.at(index) = favarite.at(index) + 1;
        }
    }

    int ans = 0;
    for (int i = 1; i <= M; i++)
    {
        if (favarite.at(i) == N)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}

int main() {
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	vl h(n);
	FOR(i,0,n) cin >> h[i];

	vl dp(n,oo);
	dp[0] = 0;

	FOR(i,0,n) {
		if (i < n - 1) {
			self_min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
		}
		if (i < n - 2) {
			self_min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}


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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
  
  int N;
  cin >> N;
  
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int g = A[0];
  
  for (int i = 1; i < N; i++) {
    g = gcd(g,A[i]);
    if(g==1) break;
  }
  
  cout << g << endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

        sc.close();

        if (a.compareTo(b) < 0) {
            System.out.println("<");
        } else if (a.compareTo(b) > 0) {
            System.out.println(">");
        } else {
            System.out.println("=");
        }

    }

}


Measured memory_bytes: 21972
N,K=map(int,input().split())
dice = list(map(int, input().split()))
a=sum(dice[0:K])

l = [a]
for i in range(1,N-K+1):
    a = a - dice[i-1] + dice[K-1+i]
    l.append(a)
print((max(l)+K)/2)


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> Q;
    REP(i,0,N) {
        ll a;
        cin >> a;
        Q.push(a);
    }

    REP(i,0,M) {
        ll v = Q.top(); Q.pop();
        Q.push(v/2);
    }

    ll sum = 0;
    while(!Q.empty()) {
        sum += Q.top();
        Q.pop();    
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 4252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n;

int main(){
	cin >> n;
	vector<ll> a(n),b(n);
	rep(i,n)cin >> a[i];
	rep(i,n)cin >> b[i];
	ll ans = 0;
	rep(k,29){
		ll cnt = 0;
		vector<ll> bb(n);
		rep(i,n)bb[i] = b[i]%(1<<(k+1));
		sort(ALL(bb));
		rep(i,n){
			ll l = (1<<k) - a[i]%(1<<(k+1)),u = (1<<(k+1)) - a[i]%(1<<(k+1));
			cnt += (lower_bound(ALL(bb),u) - lower_bound(ALL(bb),l));
			l += (1<<(k+1)), u += (1<<(k+1));
			cnt += (lower_bound(ALL(bb),u) - lower_bound(ALL(bb),l));
		}
		if(cnt%2)ans += (1<<k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

#if INPUT_FROM_FILE
#define IS ifs
#else
#define IS std::cin
#endif

int main(int argc, char **argv) {
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::vector<int> v;
	int num_operations = 0;

	IS >> n;

	v.resize(n, 0);
	for(int i = 0; i < n; i++){
		IS >> v[i];
	}

	for(int i = 0; i < n; i++){
		int mini = i;
		for(int j = i + 1; j < n; j++){
			if(v[j] < v[mini]){
				mini = j;
			}
		}
		if(i != mini){
			std::swap(v[i], v[mini]);
			num_operations++;
		}
	}

	std::cout << v[0];
	for(int i = 1; i < n; i++){
		std::cout << " " << v[i];
	}
	std::cout << std::endl;
	std::cout << num_operations << std::endl;

	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  if(n < k) cout << 1 << endl;
  else if(n == k) cout << 2 << endl;
  else {
    int i = 0;
    while(n >= std::pow(k, i)) {
      i++;
    }
    cout << i << endl;
  }  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod=1e9+7;
ll binpow(ll x,ll y)
{
	ll s=1;
	while(y)
	{
		if(y&1) {s*=x;s%=mod;}
		x=x*x;
		x%=mod;
		y>>=1;
	}
	return s%mod;
}
ll path(ll x,ll y)
{
	ll s=1;
	for(ll i=x;i<x+y-1;i++)
	{
		s*=i;
		s%=mod;
		s*=binpow(i-x+1,mod-2);
//		cout<<binpow(i-x+1,mod-2)<<endl;
		s%=mod;
	}
	return s;
}
ll a,b,n,m,sum;
int main()
{
	cin>>n>>m>>a>>b;
	ll h1=n-a;
	ll h2=m-b;
	ll dp1[h2],dp2[h2];
	dp1[0]=path(h1,b+1);
	dp2[0]=path(1,a);
	for(ll i=1;i<h2;i++)
	{
		dp1[i]=((dp1[i-1]*(i+b+h1-1))%mod*binpow(b+i,mod-2))%mod;
		dp1[i]%=mod;
	}
	for(ll i=1;i<h2;i++)
	{
		dp2[i]=((dp2[i-1]*(i-1+a))%mod*binpow(i,mod-2))%mod;
		dp2[i]%=mod;
	}
	for(ll i=0;i<h2;i++)
	{
		sum+=(dp1[i]*dp2[h2-i-1])%mod;
		sum%=mod;
	}
	cout<<sum%mod;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

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

  int H,W; cin >> H >> W;
  vector<string> G(H);
  rep(i, H) cin >> G[i];

  vector<vector<int>> DP(H, vector<int>(W, (int)1e9));
  DP[0][0] = 0;

  rep(h, H) {
    rep(w, W) {
      if(h) {
        DP[h][w] = min(DP[h][w], DP[h-1][w] + (G[h-1][w] == '.' && G[h][w] == '#' ? 1 : 0));
      }
      if(w) {
        DP[h][w] = min(DP[h][w], DP[h][w-1] + (G[h][w-1] == '.' && G[h][w] == '#' ? 1 : 0));
      }
    }
  }

  if(G[0][0] == '#') {
    DP[H-1][W-1]++;
  }

  cout << DP[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 384
module queue
  implicit none
  type :: JagArray
    integer,allocatable :: array(:)
  end type JagArray
contains
  subroutine push(A,b)
  	integer,allocatable,dimension(:)::A
    integer::b
    A=[A,b]
  end subroutine
  subroutine pop(A)
  	integer,allocatable,dimension(:)::A
    A=A(2:)
  end subroutine
end module queue

module maze
integer,allocatable,dimension(:,:)::mazemap
contains
subroutine getmap(mazemap,R,C)
  integer,allocatable,dimension(:,:)::mazemap
  integer R,C
  character(50) linereader
  allocate(mazemap(0:R+1,0:C+1))
  mazemap(0,:)=-2;mazemap(R+1,:)=-2;mazemap(:,0)=-2;mazemap(:,C+1)=-2;
  do i=1,R
    read*,linereader
    do j=1,C
      if(linereader(j:j)==".")mazemap(i,j)=-1
      if(linereader(j:j)=="#")mazemap(i,j)=-2
    end do
  end do
end subroutine
end module maze

use queue
use maze
integer,allocatable,dimension(:)::queue_x,queue_y
integer H,W
integer numcnt
integer dirx(4),diry(4)
dirx=[1,0,-1,0]
diry=[0,1,0,-1]
read*,H,W
call getmap(mazemap,H,W)

mazemap(1,1)=1
queue_x=[1]
queue_y=[1]
do while(mazemap(H,W)==-1)
  do i=1,4
    if(mazemap(queue_x(1)+dirx(i),queue_y(1)+diry(i))==-1)then
      mazemap(queue_x(1)+dirx(i),queue_y(1)+diry(i))=mazemap(queue_x(1),queue_y(1))+1
      call push(queue_x,queue_x(1)+dirx(i))
      call push(queue_y,queue_y(1)+diry(i))
    endif
  end do
  call pop(queue_x)
  call pop(queue_y)
  if(size(queue_x)==0)exit
end do

numcnt=0
do i=1,H
  do j=1,W
    if(mazemap(i,j)==-2)numcnt=numcnt+1
  end do
end do
print"(i0)",merge(-1,H*W-mazemap(H,W)-numcnt,mazemap(H,W)==-1)
end

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

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

using namespace std;
int student[10001][720];

void init(){
    REP(i,10000){
        REP(j,720){
            student[i][j] = 0;
        }
    }
    return;
}

int main(){
    int N,M,r,q;
    while(cin >> N >> M){
        if(N+M==0) break;
        init();
        cin >> r;
        REP(i,r){
            int t,n,m,s;
            cin >> t >> n >> m >> s;
            m -= 1; //0base
            if(s==1) student[m][t-540]++;
            else if(s==0) student[m][t-540]--;
        }

        //simulate
        REP(i,M){
            REP(j,720){
                if(j>0) student[i][j] += student[i][j-1];
            }
        }
        REP(i,M){
            REP(j,720){
                if(student[i][j]>0) student[i][j] = 1;
            }
        }

        cin >> q;
        REP(i,q){
            int cnt = 0;
            int t_s, t_e, m;
            cin >> t_s >> t_e >> m;
            m -= 1;
            for(int k=t_s-540 ; k<t_e-540 ; k++){
                cnt += student[m][k];
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 29284
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define endl "\n"
 
using namespace std;

const int mlt=(1<<18)+69;
const ll inf=1e18;
//TTBDC

int main()
{
  fatafat
  int n,x,t;
  cin>>n>>x>>t;
  int y = n/x;
  if(n%x!=0)y++;
  cout<<y*t;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main() {
    quickie
    int n ;
    cin >> n ;
    int x = 100 ;
    int cnt = 0 ;
    while(1) {
        int y = (1*x)/100 ;
        x += y;
        cnt++ ;
        if(x >= n) 
            break ;
    }
    cout << cnt << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int max(int a, int b)
{
	if (a < b)
		return b;
	else
		return a;
}

int main(void)
{
	int a, b, k;

	cin >> a >> b >> k;

	bool table[110][2] = {};

	int max_num = 0;

	for (int i = a; (i <= b && i < a + k); i++)
	{
		cout << i << endl;
		max_num = i;
	}

	int start = max(a, b - k + 1);
	start = max(start, max_num + 1);

	for (int i = start; (i <= b); i++)
	{
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n, x, t; cin >> n >> x >> t;

    int ans = 0;
    while (n > 0) {
        ans += t;
        n -= x;
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3644
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    T, H = map(str,input().split())
    if T > H:
        Taro += 3
    elif H > T:
        Hanako += 3
    else:
        Taro += 1
        Hanako += 1
print(Taro, Hanako)



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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N; cin >> N;
  if (N % findSumOfDigits(N) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(sc: Scanner): Unit = {
    val Array(n, k) = sc.readLineInts
    val S = sc.nextLine()
    println(S.take(k - 1) + S.charAt(k - 1).toLower + S.slice(k, n))
  }
}


Measured memory_bytes: 25540
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#define INF 10000000;
using namespace std;

int rui[100000]={};
int sosu[100000]={};
int l[100000],r[100000];
int q;
int nummax=0;

void likegene(int);
bool sosucheck(int);

void likegene(int nummax){
	int top=nummax/2;
	for(int lp=1;lp<=nummax;lp+=2){
		if(sosucheck(lp)==true && sosucheck((lp+1)/2) ==true){
			rui[lp/2]++;
			//printf("%d is 2017lik\n",lp);
		}
		else{
			//printf("%d is not 2017like\n",lp);
		}
		
		rui[lp/2]+=rui[lp/2-1];
	}
}

bool sosucheck(int num){
	if(num==1) return false;
	if(sosu[num]==2){
		return false;
	}else if(sosu[num]==1){
		return true;
	}else{
		for(int lp=2;lp<num;lp++){
			if(num%lp==0){
				sosu[num]=2;
				return false;
			}
		}
		sosu[num]=1;
		return true;
	}
}

void ruiprint(void){
	for(int lp=0;lp<=nummax/2;lp++){
		printf("%d\n",rui[lp]);
	}
}

int main(void){
	cin >>q;
	for(int lp=0;lp<q;lp++){
		scanf("%d%d",&l[lp],&r[lp]);
		if(nummax<r[lp]){
			nummax=r[lp];
		}
	}
	
	likegene(nummax);
	//ruiprint();
	
	for(int lp=0;lp<q;lp++){
		int left=l[lp]/2;
		int right=r[lp]/2;
		//printf("%d %d\n",left,right);
		if(left==0){
			printf("%d\n",rui[right]);
		}else{
			printf("%d\n",rui[right]-rui[left-1]);
		}
	}
	
	
	
	
	
	return 0;
		
	
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100, B *= 100;
    double maxp = -EPS;
    int maxw = 0.0, maxs = 0.0;
    for(int i = 0; A * i <= F; ++i){
        for(int j = 0; A * i + B * j <= F; ++j){
            int W = A * i + B * j;
            if(W == 0)  continue;
            for(int k = 0; W + C * k <= F; ++k){
                if(C * k > W / 100 * E) break;
                for(int l = 0; W + C * k + D * l <= F; ++l){
                    int S = C * k + D * l;
                    if(S > W / 100 * E) break;
                    double P = 100.0 * S / (W + S);
                    if(P > maxp){
                        maxp = P;
                        maxw = W;
                        maxs = S;
                    }
                }
            }
        }
    }
    cout << maxw + maxs << ' ' << maxs << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL H;
map<LL, LL> memo;

LL calc(LL hp) {
    if (memo.count(hp)) return memo[hp];
    if (hp == 1) return memo[hp] = 1;
    return memo[hp] = 1 + calc(hp / 2) * 2;
}

int main(void) {
    cin >> H;

    cout << calc(H) << endl;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $n, $l);
  $a = array();
  for($i = 0; $i < $n; $i++){
  	$s = trim(fgets(STDIN));
    $a[$i] = $s;
  }
	sort($a);
  foreach($a as $value){
  	echo $value;
  }

Measured memory_bytes: 15880
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b,c; cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}


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

using namespace std;

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

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE


    int n, k; cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i = 0; i < n; ++i){
        cin>>arr[i];
    }
    dp[0] = 0;
    for(int j = 1; j <= k && j < n; ++j) dp[j] = abs(arr[j]-arr[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = 1010000000;
        for(int j = 1; j <= k; ++j){
            if(i - j < 0) break;
            int pos = dp[i-j] + abs(arr[i] - arr[i-j]);
            dp[i] = min(dp[i], pos);
        }
    }
//    for(auto it : dp) cout<<it<<endl;
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.util.regex.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        System.out.println(solve(scanner.nextInt(), scanner.nextInt()) ? "Possible" : "Impossible");
    }

    static boolean solve(int h, int w) {
        for (int i = 0, x = 0; i < h; i++) {
            String a = scanner.next();
            Matcher matcher = Pattern.compile("(\\.{" + x + "}#+)\\.*").matcher(a);
            if (!matcher.matches())
                return false;
            x = matcher.group(1).length() - 1;
        }
        return true;
    }
}

Measured memory_bytes: 22864
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int a,b,c; scanf("%d %d %d", &a, &b, &c);

	int ans = 0;
	while(c > 0){
		if(b > 0){
			c--;
			b--;
			ans += 2;
			
		}else if(a > 0){
			c--;
			a--;
			ans++;
		}else{
			ans++;
			break;
		}
	}

	while(b > 0){
		b--;
		ans++;
	}

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

}


Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  vector<int> v;
  int n{};
  char b{};
  for (char c : S) {
    if (b != c && n) {
      v.push_back(n);
      n = 0;
    }
    b = c;
    ++n;
  }
  v.push_back(n);

  ll ans{};
  if (v.size() == 1) {
    ans = K * v[0] / 2;
  } else if (S[0] == S.back()) {
    ans = K * accumulate(begin(v) + 1, end(v) - 1, 0ll,
                         [](ll a, int x) { return a + x / 2; });
    ans += (v[0] + v.back()) / 2 * (K - 1) + v[0] / 2 + v.back() / 2;
  } else {
    ans = K * accumulate(begin(v), end(v), 0ll,
                         [](ll a, int x) { return a + x / 2; });
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define INF (1<<29)
int l;
ll a[200005];
//ll a;
ll dp[200005][5]={0};
int main(){
    cin>>l;
    for(int i=0;i<l;i++) cin>>a[i];
    
    /*for(int i=0;i<5;i++){
        for(int j=0;j<l+2;j++){
            dp[j][i]=INF;
        }
    }*/
    
    //for(int i=0;i<5;i++) dp[0][i]=0;
    
    for(int i=1;i<=l;i++){
        //cin>>a[i-1];
        int b=(a[i-1]==0?2:(a[i-1]%2));
        
        int c=!(a[i-1]%2);
        
        dp[i][0]=dp[i-1][0]+a[i-1];
        
        dp[i][1]=min(dp[i][0],dp[i-1][1]+b);
        
        dp[i][2]=min(dp[i][1],dp[i-1][2]+c);
        
        dp[i][3]=min(dp[i][2],dp[i-1][3]+b);
        
        dp[i][4]=min(dp[i][3],dp[i-1][4]+a[i-1]);
        
    }
    cout<<dp[l][4]<<endl;
    return 0;
    
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;


ll plist[200001];
vector<int> d[200001];
//vector<int> y[200001];//有方向はこっちにまとめる
bool used[200001];


int main(){
    int N,Z;
    cin>>N>>Z;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        d[a].push_back(b);
        d[b].push_back(a);
    }

    for(int i=0;i<Z;i++){
        int p;
        ll x;
        cin>>p>>x;
        plist[p]+=x;
    }
    
    queue<int> Q;

    Q.push(1);
    while(!Q.empty()){
        int x=Q.front();
        //cout<<x<<endl;
        for(int i=0;i<d[x].size();i++){
            int k=d[x].at(i);
            if(!used[k]) {
                Q.push(k);
                plist[k]+=plist[x];
            }
        }
        used[x]=true;    
        Q.pop();
    }

    for(int i=1;i<=N;i++) cout<<plist[i]<<' ';
    cout<<endl;
    

    

}

Measured memory_bytes: 16500
#include<stdio.h>

int main(void){
    int a, b, c, k;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    c = 0;

    for(int i = 1; i * k <=b; i++){
        if (i*k >= a && i*k <= b)
        {
            c++;
            break;
        }
    }
    if(c != 0){
        printf("OK\n");
    }   else
    {
        printf("NG\n");
    }
    
    return 0;
}

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

int main(void) {
  string s1, s2, s3;
  vector<string> keys;
  cin >> s1 >> s2;
  int l1 = s1.size();
  int l2 = s2.size();
  bool ans = false;
  int i, j;
  for (i = 0; i <= l1 - l2; i++) {
    s3 = s1;
    for (j = 0; j < l2; j++) {
      if (s3[i + j] != s2[j] && s3[i + j] != '?') {
        s3 = s1;
        break;
      }
      s3[i + j] = s2[j];
    }
    if (j == l2) {
      for (int k = 0; k < s3.size(); k++) {
        if (s3[k] == '?')
        s3[k] = 'a';
      }
      keys.push_back(s3);
    }
  }
  sort(keys.begin(), keys.end());
  cout << (keys.size() != 0 ? *keys.begin() : "UNRESTORABLE") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,e,j;
  while(1){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>m>>e>>j;
      if((m==100||e==100||j==100)||(m+e)/2>=90||(m+e+j)/3>=80){
	cout<<'A'<<endl;
	continue;
      }else  if((m+e+j)/3>=70||((m+e+j)/3>=50&&m>=80||e>=80)){
	cout<<'B'<<endl;
	continue;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return(0);
}



Measured memory_bytes: 3048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int a,b;
	cin>>a>>b;
	if(a<=5)cout<<0<<endl;
	else if(a<=12)cout<<b/2<<endl;
	else cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const ll MAX_N = ll(1e5);
ll N, a[MAX_N * 3];

void solve() {
    ll ans = 0;
    sort(a, a + 3 * N);
    for (ll i = 3 * N - 2; i >= N; i -= 2) ans += a[i];
    cout << ans << endl;
}

int main() {
    cin >> N;
    REP(i, 3 * N) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
card = []
d = {'S' : 0,'H' : 1,'C' : 2,'D' : 3}
dd = {0 : 'S',1 : 'H',2 : 'C',3 : 'D'}
flag = [[1 for j in range(13)] for i in range(4)]

for i in range(N):
    a = input().split()
    card.append(a)

for s,rank in card:
    flag[d[s]][int(rank)-1] = 0

for i in range(4):
    for j in range(13):
            if flag[i][j] == 1:
                print(dd[i],j+1)



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

const int N=5005;
const long long inf=1e18;
int n,a[N],g[N][N],num_edge[N],G[N];
long long f[N][N],F[N];
vector<int>adj[N];

void dfs(int u,int p)
{
    for(int v:adj[u])
    {
        if(v!=p)
        {
            dfs(v,u);
            num_edge[u]+=num_edge[v]+1;
        }
    }
    int m=0;
    f[u][0]=a[u];
    g[u][0]=(a[u]>0);
    for(auto&v:adj[u])
    {
        if(v==p) continue;
        for(int i=0;i<=m+num_edge[v]+1;i++)
        {
            F[i]=inf;
            G[i]=0;
        }
        for(int i=0;i<=m;i++)
        {
            for(int j=0;j<=num_edge[v];j++)
            {
                F[i+j]=min(F[i+j],f[u][i]+f[v][j]);
                if(f[v][j]<0||g[v][j]) F[i+j+1]=min(F[i+j+1],f[u][i]);
                if(g[u][i])
                {
                    if(g[v][j]) G[i+j]=1;
                    if(f[v][j]<0) G[i+j+1]=1;
                }
            }
        }
        m+=num_edge[v]+1;
        for(int i=0;i<=m;i++)
        {
            f[u][i]=F[i];
            g[u][i]=G[i];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,0);
    for(int i=0;i<n;i++)
    {
        if(f[1][i]<0||g[1][i]) return cout<<i,0;
    }
}


Measured memory_bytes: 251008
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




int fac[310000];

int inv(int x){
  if(x==1) return 1;
  return (M-M/x)*inv(M%x)%M;
}


int comb(int n,int k){
  if(n<0||k<0||n<k) return 0;
  int x=(fac[k]*fac[n-k])%M;
  return (fac[n]*inv(x))%M;
}

int fac_init(int n){
  fac[0]=1;
  FOR(i,1,n+1){
    fac[i]=fac[i-1]*i;
    fac[i]%=M;
  }
}




ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}


main(){
  int n,k;
  cin>>n>>k;
  fac_init(n+k);
  int res=0;

  FOR(i,1,k+1){
    cout<<(comb(n-k+1,i)*comb(k-1,i-1))%M<<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

ll modpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	a %= m;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

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

	ll s;
	cin >> s;
	ll ans = s / 8;
	vector<ll> vec;
	for (int i = 1; i * i <= s; i++) {
		if (s % i == 0) {
			if (i >= 8) vec.pb(i);
			if (s / i >= 8 && i != s / i) vec.pb(s / i);
		}
	}
	for (int i : vec) {
		ans--;
		ans += 9 * modpow(10, i - 1) % mod;
		ans -= s / i - 1;
		ans %= mod;
	}
	vector<ll> cnt = { 0,9,90,900,9000,90000,900000,9000000,90000000,900000000 };
	for (int i = 1; i <= 7; i++) {
		for (int j = i; j <= 8; j++) {
			if (i == j) {
				if (s > 0 && s % i == 0) {
					ll rem = s / i;
					if (rem <= cnt[i]) ans += cnt[i] - rem + 1;
				}
			}
			else {
				for (ll x = 1; x <= cnt[i]; x++) {
					ll t = s;
					t -= x * i;
					for (int k = i + 1; k < j; k++) {
						t -= cnt[k] * k;
					}
					if (t > 0 && t % j == 0) {
						ll rem = t / j;
						if (rem <= cnt[j]) {
							ans++;
						}
					}
				}
			}
		}
	}
	ans %= mod;
	if (ans < 0) ans += mod;
	cout << ans << '\n';
}

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

using namespace std;

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

int main(){
	int N;
	int f[200];
	static int dp1[1000000], dp2[1000000];
	rep(i, 200) f[i] = i*(i+1)*(i+2)/6;
	dp1[0] = dp2[0] = 0;
	REP(i, 1, 1000000){
		dp1[i] = dp2[i] = i;
		for(int j=0; f[j]<=i; j++){
			dp1[i] = min(dp1[i], dp1[i-f[j]]+1);
			if(f[j]%2==1) dp2[i] = min(dp2[i], dp2[i-f[j]]+1);
		}
	}
	while(cin >> N, N)
		cout << dp1[N] << " " << dp2[N] << endl;
}



Measured memory_bytes: 10896
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
class Bit {
	std::vector<int> vec;
public:
	Bit(int size) : vec(size, 0) {}
	void add(int position, int value) {
		while (position < vec.size()) {
			vec[position] += value;
			position += ~position & (position + 1);
		}
	}
	int get(int position) const {
		int result = 0;
		while (position >= 0) {
			result += vec[position];
			position -= ~position & (position + 1);
		}
		return result;
	}
};
int main() {
	int n; long long int k; std::cin >> n >> k;
	std::vector<long long int> values(n); for (auto& v : values) std::cin >> v;
	std::vector<long long int> sum{ 0 }; for (auto v : values) sum.push_back(sum.back() + v);
	std::vector<int> indices(n + 1); std::iota(indices.begin(), indices.end(), 0);
	std::sort(indices.begin(), indices.end(), [&sum, k](int a, int b) {return (sum[a] - a * k == sum[b] - b * k) ? a < b : (sum[a] - a * k < sum[b] - b * k); });
	Bit bit(n + 1);
	long long int count = 0;
	for (const auto idx : indices) {
		count += bit.get(idx);
		bit.add(idx, 1);
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 5156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> d(n);
  vector<int> parent(n, -1);
  vector<int> p(n);
  vector<ll> size(n, 1);
  map<ll, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    p[i] = i;
    mp[d[i]] = i;
  }
  sort(p.begin(), p.end(), [&](int i, int j) { return d[i] > d[j]; });
  int r = p.back();
  p.pop_back();
  for (int i : p) {
    ll tmp = d[i] - n + 2 * size[i];
    if (tmp < d[i] && mp.count(tmp)) {
      parent[i] = mp[tmp];
      size[parent[i]] += size[i];
    } else {
      cout << -1 << '\n';
      return 0;
    }
  }
  vector<ll> sum(n);
  for (int i : p) {
    sum[parent[i]] += sum[i] + size[i];
  }
  reverse(p.begin(), p.end());
  vector<ll> correct(n);
  correct[r] = sum[r];
  for (int i : p) {
    correct[i] = correct[parent[i]] + n - 2 * size[i];
  }
  if (correct != d) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (parent[i] != -1) {
      cout << i+1 << ' ' << parent[i]+1 << '\n';
    }
  }
}


Measured memory_bytes: 11648
import java.util.*;

class Main {
	Scanner sc;
	int N;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		
		System.out.println( (N+1)/2 );
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 35784
sx,sy,tx,ty = gets.split.map!(&:to_i)

a = tx - sx
b = ty - sy

n = "R" * a + "U" * b + "L" * a + "D" * b
m = "D" + "R" * (a + 1) + "U" * (b + 1) + "L"
l = "U" + "L" * (a + 1) + "D" * (b + 1) + "R"

puts n + m + l

Measured memory_bytes: 1916
#include<complex>
#include<iostream>

using namespace std;

typedef complex<double> P;

// ?¨±?????????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2??????????????????????????????????????????
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

// ?????? (dot product) : a???b = |a||b|cos??
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// ?????? (cross product) : a??b = |a||b|sin??
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected_ls(P a1, P a2, P b1, P b2) {
	return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS) &&
		(cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < EPS);
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
	return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

// ???c?????????a,b????????????????????????(1)
int is_point_on_line(P a, P b, P c) {
	return EQ(cross(b - a, c - a), 0.0) &&
		(dot(b - a, c - a) > -EPS) &&
		(dot(a - b, c - b) > -EPS);
}

int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		double x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
		if (is_point_on_line(p0, p1, p2)
			|| is_point_on_line(p0, p1, p3)
			|| is_point_on_line(p2, p3, p0)
			|| is_point_on_line(p2, p3, p1)) {
			cout << 1 << endl;
			continue;
		}
		if (is_parallel(p0, p1, p2, p3)) {
			cout << 0 << endl;
			continue;
		}
		cout << is_intersected_ls(p0, p1, p2, p3) << endl;
	}
}

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


def main():
    n = int(input())
    abc = [[0 for _ in range(3)] for _ in range(n)]
    dp = [[0 for _ in range(3)] for _ in range(n + 1)]

    for i in range(n):
        ai, bi, ci = map(int, input().split())
        abc[i][0] = ai
        abc[i][1] = bi
        abc[i][2] = ci

    # See:
    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue

                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])

    print(max(dp[n]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 45720
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>

# define FILE
using namespace std;

const int N = 1e5 + 100;

int n, ans[N];
string s;

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

    cin >> s;
    n = s.size();
    int cnt = 0;
    for( int i = 0; i < n; i ++ ){
        if( s[i] == 'R' )
            cnt++;
        else if( cnt != 0 ){
            ans[i-1] += cnt/2+cnt%2;
            ans[i] += cnt/2;
            cnt = 0;
        }
    }
    for( int i = n-1; i >= 0; i -- ){
        if( s[i] == 'L' )
            cnt ++;
        else if( cnt != 0 ){
            ans[i+1] += cnt/2+cnt%2;
            ans[i] += cnt/2;
            cnt = 0;
        }
    }
    for( int i = 0; i < n; i ++ ){
        cout << ans[i] << ' ';
    }
    return 0;
}


Measured memory_bytes: 1104