akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;


int main()
{
    int n,m,l;
    long a[100][100],b[100][100],c[100][100]={0};
    cin>>n>>m>>l;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k] * b[k][j];
            }
            cout<<c[i][j];
            if(j!=l-1)  cout<<' ';
        }
        cout<<'\n';
    }
}


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

int main() {
	ll a,b,n;
	cin>>a>>b>>n;
	if(n>=b)
		cout<<floor(a*(b-1)/b)<<endl;
	else
		cout<<floor(a*(n)/b)<<endl;
	return 0;
}


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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ac = a * c;
  ll ad = a * d;
  ll bc = b * c;
  ll bd = b * d;
  ll result = max(ac, max(ad, max(bc, bd)));
  cout << result << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
 
const ll MOD = 1e9 + 7;
 
/* Commonly used stuff */
 
ll gcd(ll a, ll b){
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
 
bool isPrime(ll n){
	if(n <= 1)
		return false;
	for(ll i = 2; i <= sqrt(n); ++i){
		if(n % i == 0)
			return false;
	}
	return true;
}
 
ll modExp(ll b, ll e, ll mod){
	ll res = 1;
	while(e > 0){
		if(e & 1)
			res = res * b % mod;
		b = b * b % mod;
		e>>=1;
	}
	return res % mod;
}
 
ll factorial(ll n){
	ll r = 1;
	for(ll i = 1; i <= n; ++i){
		r *= i;
	}
	return r;
}
 
//////////////////////////
/* Put globals here */
string s;
int n;

int main(){
	cin>>n>>s;
	for(int i = 0; i < s.size(); ++i){
		s[i] = s[i] + n;
		if(s[i] > 'Z')
			s[i] = 'A' + (s[i] - 'Z') - 1;
	}
	cout<<s<<endl;												
    return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5", "WEEWW" ].solve == 1 );
	assert( [ "12", "WEWEWEEEWWWE" ].solve == 4 );
	assert( [ "8", "WWWWWEEE" ].solve == 3 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	
	auto wts = new long[ 1 + s.length ];
	foreach( i, c; s )
	{
		wts[ i + 1 ] = wts[ i ] + ( c == 'W' );
	}
	auto ets = new long[ s.length + 1 ];
	foreach_reverse( i, c; s )
	{
		ets[ i ] = ets[ i + 1 ] + ( c == 'E' );
	}
	
	auto ans = long.max;
	foreach( i; 0L .. s.length.signed )
	{
		ans = min( ans, wts[ i ] + ets[ i + 1 ] );
	}
	
	return ans;
}


Measured memory_bytes: 9320
fun main(args: Array<String>) {
    val l = readLine()!!.split(" ").map { it.toLong() }
    var res = 0L
    for (i in l[1] until l[0]+2) {
        val min = i*(i-1)/2
        val max = l[0]*i - min
        res += max-min+1
    }
    println(res % 1000000007)
}


Measured memory_bytes: 36572
import java.util.*;


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


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

const int mod = 1000000007;
int d;
int l[300];
int s;
int dp[2][90010][2];
using ll = long long;

ll modpow(ll x, int y){
    if(y == 0) return 1;
    ll a = modpow(x, y/2);
    a *= a;
    a %= mod;
    if(y&1){
        a *= x;
        a %= mod;
    }
    return a;
}

int main(){
    while(cin >> d){
        for(int i = 0; i < d; ++i) cin >> l[i];
        cin >> s;
        memset(dp, 0, sizeof dp);
        dp[0][0][0] = 1;
        for(int i = 0; i < d; ++i){
            auto a = dp[i&1];
            auto b = dp[~i&1];
            memset(b, 0, sizeof dp[0]);
            for(int j = 0; j <= s; ++j){
                for(int p : {0,1}){
                    (b[j][p] += a[j][p]) %= mod;
                    if(j+l[i] <= s) (b[j+l[i]][p^1] += a[j][p]) %= mod;
                }
            }
        }
        ll ans = 0;
        for(int i = 0; i <= s; ++i){
            ll x = dp[d&1][i][0] * modpow(s-i, d) % mod;
            ll y = dp[d&1][i][1] * modpow(s-i, d) % mod;
            ans += x - y + mod;
        }
        ans %= mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4504
#include <stdio.h>
#define N 100000



typedef struct Card{
char c;
int a;
  int anna;
}Cards;

int Partition(int, int);
void Quicksort(int, int);
Cards A[N];

main()
{
  int n,i,j,f=0;
  char cc;

  scanf("%d%c",&n,&cc);
  
  for(i = 0; i < n; i++){
    scanf("%c%d%c",&A[i].c,&A[i].a,&cc);
    A[i].anna = i;
  }
  
  Quicksort(0, n-1);
  for(i = 0; i < n-1; i++){
    if(A[i].a == A[i+1].a && A[i].anna > A[i+1].anna){
      f = 1;
    }
  }
  if(f == 1){
    printf("Not stable\n");
  }
  else {
    printf("Stable\n");
  }
  for(i = 0; i < n; i++){
    printf("%c %d\n",A[i].c,A[i].a);
  }
  return 0;
}


int Partition(p, r)
{

  int i,j,x;
  Cards tmp;

  x = A[r].a;
  i = p-1;

  for(j = p; j <= r-1; j++){
    if(A[j].a <= x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;

}

void Quicksort(int p, int r)
{
  int q;

  if(p < r){
    q = Partition(p, r);
    Quicksort(p, q-1);
    Quicksort(q+1, r);
  }
}

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

int main() {
	double X;
	cin >> X;
	int tmp = ceil(X / 105);

	if (100 * tmp <= X && X <= 105 * tmp) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
// AtCoder Beginner Contest - Problem C: 755 (https://atcoder.jp/contests/abc114/tasks/abc114_c)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAX { 1000000000LL };

vector<int> xs;

void solve(int N)
{
    auto ans = lower_bound(xs.begin(), xs.end(), N + 1) - xs.begin();

    cout << ans << endl;
}

void precomp(ll N)
{
    if (N >= MAX)
        return;

    auto M = N;
    int found = 0;
    
    while (M)
    {
        auto d = M % 10;
        M /= 10;

        if (d == 3)
            found |= 1;

        if (d == 5)
            found |= 2;

        if (d == 7)
            found |= 4;

    }

    if (found == 7)
        xs.push_back(N);

    const vector<int> ds { 3, 5, 7 };

    for (const auto& d : ds)
        precomp(10*N + d);
}

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

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

    int N;
    cin >> N;

    solve(N);

    return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n, c, k;
  cin >> n >> c >> k;
  V<int> t(n);
  rep(i,n) cin >> t[i];
  sort(all(t));
  int cnt = 0;
  int p = 0;
  int time = -1;
  rep(i,n) {
    if(time < t[i] || p == c) {
      p = 1;
      cnt++;
      time = t[i] + k;
    }
    else p++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3668
#include <vector>
#include <map>
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;
int L,N;
ll w[31],x[31];
vector<P> ans;
int main() {
    cin>>L>>N;
    rep(i,N) cin>>x[i]>>w[i];

    ll sum=0;
    rep(i,N) sum+=x[i]*w[i];

    int t=1;
    if(sum>0) t=-1;
    sum=abs(sum);

    while(sum>L) {
        sum-=L;
        ans.push_back(P(1,t*L));
    }

    ans.push_back(P(1,t*sum));
    cout<<ans.size()<<endl;
    rep(i,ans.size()) cout<<ans[i].second<<" "<<ans[i].first<<endl;
    

    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 100; ++i) {
        if(1+(a-1)*i >= b){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
enum class Direction: char {
	East, South
};
std::istream& operator>>(std::istream& is, Direction& dir) {
	char c; is >> c;
	switch (c) {
	case 'E': dir = Direction::East; break;
	case 'S': dir = Direction::South; break;
	default: throw 0;
	}
	return is;
}
struct Ant {
	int x, y, id;
	Direction dir;
	int time_until_drop(int w, int h) const {
		switch (dir) {
		case Direction::East: return w - x + 1;
		case Direction::South: return h - y + 1;
		default: throw 0;
		}
	}
};
int main() {
	int w, h, n; std::cin >> w >> h >> n;
	std::vector<Ant> ants(n);
	for (auto i = 0; i < n; ++i) {
		ants[i].id = i + 1;
		std::cin >> ants[i].x >> ants[i].y >> ants[i].dir;
	}
	std::sort(ants.begin(), ants.end(), [](const Ant& a, const Ant& b) {return (a.y + a.x == b.y + b.x) ? a.x < b.x : a.y + a.x < b.y + b.x; });
	std::vector<std::queue<int>> queue(2);
	for (auto current = ants.begin(); current != ants.end(); ) {
		auto last = std::upper_bound(current, ants.end(), current->y + current->x, [](const int val, const Ant& a) {return val < a.y + a.x; });
		for (auto itr = current; itr != last; ++itr) {
			switch (itr->dir) {
			case Direction::South:
				if (!queue[itr->y % 2].empty()) {
					queue[itr->y % 2].push(itr->id);
					itr->id = queue[itr->y % 2].front(); queue[itr->y % 2].pop();
				}
				break;
			case Direction::East: queue[itr->x % 2].push(itr->id); break;
			default: throw 0;
			}
		}
		for (; current != last; ++current) {
			switch (current->dir) {
			case Direction::South: break;
			case Direction::East: current->id = queue[current->x % 2].front(); queue[current->x % 2].pop(); break;
			default: throw 0;
			}
		}
	}
	std::sort(ants.begin(), ants.end(), [w, h](const Ant& a, const Ant& b) {return (a.time_until_drop(w, h) == b.time_until_drop(w, h)) ? a.id < b.id : a.time_until_drop(w, h) < b.time_until_drop(w, h); });
	for (const auto& ant : ants) std::cout << ant.id << '\n';
}


Measured memory_bytes: 6492
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] c = new int[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < n; i++){
            ans += Integer.parseInt(sc.next());
        }
        for(int i = 1; i < n; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        
        for(int i = 0; i < n-1; i++){
            if(a[i] +1 == a[i+1]){
                ans += c[a[i]];
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll cnt = 0;

  rep(i, 100){
    if((A <= i) && (i < B) && (C <= i) && (i < D)) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

int H,W,i,j;

while(1){
scanf("%d %d",&H,&W);
if(H==0 && W==0) break;

for(i=0;i<W;i++){
printf("#");
}
printf("\n");

for(i=0;i<H-2;i++){

printf("#");
for(j=0;j<W-2;j++){
printf(".");
}
printf("#\n");
}

for(i=0;i<W;i++){
printf("#");
}
printf("\n");
	printf("\n");	
}

return 0;
}


Measured memory_bytes: 2044
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    ans=float("inf")
    for x in range(-100,101):
        cnt=0
        for i in range(n):
            cnt+=(a[i]-x)**2
        ans=min(ans,cnt)

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

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String[] arsgs){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int count = 0;
    String ans  = "No";
    if((a == b) || (a == c) ||(b == c)){
      if(!(a ==b && a == c)){
        ans = "Yes";
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int X, Y, Ans;
int Dx[] = { 1,0,-1,0 };
int Dy[] = { 0,1,0,-1 };
bool Used[10][10];


void show(int s[10][10]) {
	char ch;

	for (int i = 0; i < Y; i++) {
		for (int j = 0; j < X; j++) {
			if (s[i][j] == 0) {
				ch = 'R';
			}
			else if (s[i][j] == 1) {
				ch = 'G';
			}
			else {
				ch = 'B';
			}
			cout << ch << " ";
		}
		cout << endl;
	}
	cout << "--\n";
}

bool judge(int(*p)[10]) {
	for (int i = 0; i < Y; ++i) {
		for (int j = 0; j < X; ++j) {
			if (p[i][j] != p[0][0]) {
				return false;
			}
		}
	}

	return true;
}

void nextState(int (*pSource)[10], int (*pTo1)[10], int (*pTo2)[10]) {
	int color1, color2, nowX, nowY;
	queue<pair<int, int> > convert;

	if (pSource[0][0] == 0) {
		color1 = 1;
		color2 = 2;
	}
	else if (pSource[0][0] == 1) {
		color1 = 0;
		color2 = 2;
	}
	else {
		color1 = 0;
		color2 = 1;
	}

	for (int i = 0; i < Y; ++i) {
		for (int j = 0; j < X; ++j) {
			pTo1[i][j] = pTo2[i][j] = pSource[i][j];
		}
	}
	
	memset(Used, false, sizeof(Used));
	convert.push(make_pair(0, 0));
	Used[0][0] = true;
	pTo1[0][0] = color1;
	pTo2[0][0] = color2;

	while (!convert.empty()) {
		pair<int, int> temp;
		temp = convert.front();
		convert.pop();

		for (int i = 0; i < 4; ++i) {
			nowX = temp.first + Dx[i];
			nowY = temp.second + Dy[i];

			if (nowX<0 || nowX>=X || nowY<0 || nowY>=Y) {
				continue;
			}
			if (Used[nowY][nowX]) {
				continue;
			}
			if (pSource[nowY][nowX] != pSource[0][0]) {
				continue;
			}
			Used[nowY][nowX] = true;
			pTo1[nowY][nowX] = color1;
			pTo2[nowY][nowX] = color2;
			convert.push(make_pair(nowX, nowY));
		}
	}

}

void solve(int (*p)[10], int cnt) {

	if (judge(p)) {
		Ans = min(Ans, cnt);
		return;
	}
	if (cnt >= Ans) {
		return;
	}

	int Tmp1[10][10], Tmp2[10][10];

	nextState(p, Tmp1, Tmp2);
	solve(Tmp1, cnt + 1);
	solve(Tmp2, cnt + 1);
}

int main() {
	char c;
	int mapData[10][10];

	while (cin >> X >> Y, X) {
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				cin >> c;
				if (c == 'R') {
					mapData[i][j] = 0;
				}
				else if (c == 'G') {
					mapData[i][j] = 1;
				}
				else if (c == 'B') {
					mapData[i][j] = 2;
				}
			}
		}
		//show(mapData);
		Ans = 20;
		solve(mapData, 0);
		cout << Ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3112
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
    num=a[i]
    j=i-1
    while j>=0 and a[j]>num:
        a[j+1]=a[j]
        j-=1
    a[j+1]=num
    print(*a)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void Pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    repr(i, 1, 10){
        repr(j, 1, 10){
            if(i*j==n) Pr(1);
        }
    }
    Pr(0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;

void dfs(int now, int parent, int add,vector<vector<int>> &children,vector<int> &ans,vector<int> &x) {
    ans.at(now)+=add;
    ans.at(now)+=x.at(now);
    for(int child : children.at(now)) {
        if(child == parent) continue;
        dfs(child, now, ans.at(now), children,ans,x);
    }
}
int main(){
    int n,q;
    cin>>n>>q;
    vector<vector<int>> children(n,vector<int>());
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        children.at(a).push_back(b);
        children.at(b).push_back(a);
    }
    
    vector<int> x(n,0);
    rep(i,0,q){
        int p,y;
        cin>>p>>y;
        p--;
        x.at(p)+=y;
    }
    
    vector<int> ans(n);
    dfs(0,-1,0,children,ans,x);
    rep(i,0,n){
        cout<<ans.at(i);
        if(i==n-1) cout<<endl;
        else cout<<" ";
    }
}


Measured memory_bytes: 33664
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int n;
	while(cin >> n, n) {
		int ret = 0;
		while(1) {
			if(n==1) break;
			if(n%2==0) {
				n/=2;
				ret++;
			} else {
				n = n*3+1;
				ret++;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll a,b,c; cin>>a>>b>>c;
    cout<<(a%c ?b/c-a/c:b/c-a/c+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int n;
    cin >> n;
    ostringstream ss;
    ss << n;
    string res = "ABC" + ss.str();
    cout << res << "\n";
}


Measured memory_bytes: 256
N, K= map(int, input().split())
A = map(int, input().split())
d = {}
for a in A:
    if a in d:
        d[a] = d[a] + 1
    else:
        d[a] = 1
o = []
for k, v in d.items():
    o.append(v)
o = sorted(o, reverse=True)

if K >= len(o):
    print(0)
else:
    print(sum(o[K:]))

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


int main(){
  
  string T, S;
  cin>>S>>T;
  int i, mx=0, Ns=S.size()-T.size(), Nt=T.size();
  for(int i=0; i<=Ns; i++){
    int cnt=0;
    for(int j=0; j<Nt; j++){
      if(T[j]==S[i+j]) cnt++;
    }
    mx=max(mx, cnt);
  }
  cout<<Nt-mx<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int Ismin(int i);
int a[15];
int main()
{
	int n,k,t;
	scanf("%d %d",&n,&k);
	for(int i = 0;i < k; i++)
	{
		scanf("%d",&t);
		a[t] = 1;
	}
	for(int i = n;;i++)
	{
		if(Ismin(i))
		{
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}


int Ismin(int i)
{
	int x,flag = 0;
	while(i)
	{
		x = i % 10;
		if(a[x])
		{
			flag = 1;
			return 0;
		}
			i /= 10;
	}
	return 1;
}


Measured memory_bytes: 128
def smpl(m,y,r):
    return m*(1+y*r/100.0)

def cmpnd(m,y,r):
    return m*pow((1+r/100.0),y)

while True:
    n=input()
    if n==0:break
    y=input()
    dic={}
    for i in range(n):
        b,r,t=map(int,raw_input().split())
        rate=smpl(10000,y,r) if t==1 else cmpnd(10000,y,r)
        dic[rate]=b
    print dic[max(dic)]

Measured memory_bytes: 4364
package main

import "fmt"

func main() {
	var x int
	fmt.Scanf("%d", &x)

	var depo int = 100
	var count int = 1

	for {
		interest := depo / 100
		depo = depo + interest

		if depo >= x {
			break
		}
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 1820
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
using namespace std;

int main() {
	int N;
	cin >> N;
	int rate[N];
	int max=0;
	int min=0;
	bool color[8];
	for(int i=0; i < 8; i++){
		color[i]=true;
	}
	for(int i=0; i < N; i++){
		cin >> rate[i];
		if(rate[i]>=3200){
			max++;
		}
		else if(color[rate[i]/400]){
			max++;
			min++;
			color[rate[i]/400]=false;
		}
	}
	if(min==0) min = 1;
	cout << min << " " << max << endl;

	return 0;
}


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

int main(){
	int taro[105],hanako[105],nt,nh,i,j,d=0,d2;
	int min=100000,mint=-1,minh=-1;
	while(1){
		scanf("%d %d",&nt,&nh);
		if(nt==0 && nh==0)
			break;
		d=0;
		min=100000;
		mint=-1;
		minh=-1;
		for(i=0;i<nt;i++){
			scanf("%d",&taro[i]);
			d+=taro[i];
		}
		for(i=0;i<nh;i++){
			scanf("%d",&hanako[i]);
			d-=hanako[i];
		}
		//printf(":%d\n",d);
		for(i=0;i<nt;i++){
			for(j=0;j<nh;j++){
				d2=-taro[i]+hanako[j];
		//printf(":%d",d2);
				if(d==d2*(-2) && min>=taro[i]+hanako[j]){
					min=taro[i]+hanako[j];
					mint=i;
					minh=j;
				}
			}
		}
		if(mint==-1){
			printf("-1\n");
		}else{
			printf("%d %d\n",taro[mint],hanako[minh]);
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

static const int MOD = 1000000007;

long long power(long long x, long long n, long long M) {//x^n % Mを返す
	long long res = 1;
	if (n > 0) {
		res = power(x, n / 2, M);
		if (n % 2 == 0) res = (res*res) % M;
		else res = (((res*res) % M)*x) % M;
	}
	return res;
}

signed main() {
	int N;
	int A[100005];
	cin >> N;

	REP(i, N) {
		cin >> A[i];
	}
	
	
	int oe = (N + 1) % 2;
	REP(i, N) {
		if (A[i] % 2 != oe) {
			cout << 0 << endl;
			return 0;
		}
	}


	sort(A, A + N);

	if (oe == 0) {
		if (A[0] != 0) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 1;i < N;i += 2) {
			if (A[i] != i + 1 || A[i + 1] != i + 1) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = 0;i < N;i += 2) {
			if (A[i] != i + 1 || A[i + 1] != i + 1) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	cout << power(2, N/2, MOD) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
long long int mod = 1e9+7;

int main(){
    go(); 

    // code here
    int n,m,k;cin>>n>>m>>k;
    int cost[n];
    vector<vector<int>> arr(n,vector<int>(m));
    forn(0,n,1){
        cin>>cost[i];
        for(int j = 0; j < m; j++){
            cin>>arr[i][j];
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i < (1<<n); i++){
        vector<int> temp(m,0);
        int temp_c = 0; 
        for(int j = 0; j < n;j++){
            if(i&(1<<j)){
                for(int k = 0;k < m;k++){
                    temp[k] += arr[j][k]; 
                }
                temp_c += cost[j];
            }
        }
        int flag = 0;
        for(int x:temp){
            if(x<k){
                flag = 1;
                break;
            }
        }
        if(flag == 0) ans = min(ans,temp_c);
    }
    if(ans==INT_MAX) cout<<-1;
    else cout<<ans;
}





Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int HEIGHT, WIDTH;
vector<vector<int>> S;
pair<int, int> START;
deque<pair<int, int>> STACK;
vector<vector<int>> M;

void read() {
  cin >> HEIGHT >> WIDTH;
  for (int i = 0; i < HEIGHT; i++) {
    vector<int> ROW;
    for (int j = 0; j < WIDTH; j++) {
      char c;
      cin >> c;
      ROW.push_back(c == '.' ? 0 : -1);
    }
    S.push_back(ROW);
  }
}

void bfs(int i, int j) {
  vector<pair<int, int>> vectors = {make_pair(1, 0), make_pair(-1, 0),
                                    make_pair(0, 1), make_pair(0, -1)};
  for (auto v : vectors) {
    int ii = i + v.first;
    int jj = j + v.second;

    if (0 <= ii && ii < HEIGHT && 0 <= jj && jj < WIDTH) {
      if (ii == START.first && jj == START.second) {
        continue;
      }

      if (M.at(ii).at(jj) == 0) {
        M.at(ii).at(jj) = M.at(i).at(j) + 1;
        STACK.push_back(make_pair(ii, jj));
      }
    }
  }
}

vector<vector<int>> deep_copy_matrix(vector<vector<int>> src) {
  vector<vector<int>> matrix;
  for (int i = 0; i < HEIGHT; i++) {
    vector<int> row;
    for (int j = 0; j < WIDTH; j++) {
      row.push_back(src.at(i).at(j));
    }
    matrix.push_back(row);
  }
  return matrix;
}

int max_of_matrix(vector<vector<int>> matrix) {
  int ans = 0;
  for (auto row : matrix) {
    for (auto n : row) {
      ans = max(ans, n);
    }
  }
  return ans;
}

int main() {
  read();

  int ans = 0;
  for (int i = 0; i < HEIGHT; i++) {
    for (int j = 0; j < WIDTH; j++) {
      START = make_pair(i, j);
      STACK.push_back(START);
      M = deep_copy_matrix(S);
      while (STACK.size() > 0) {
        auto p = STACK.front();
        STACK.pop_front();
        bfs(p.first, p.second);
      }
      ans = max(ans, max_of_matrix(M));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = make_divisors(n)
# print(ans)

m = INF
for i in range(len(ans)//2+1):
    c = ans[i] - 1 + ans[-i-1] - 1
    # print(c)
    m = min(m,c)
print(m)

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

#include <atcoder/all>
using namespace atcoder;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    dsu d(N);
    rep(i, M) d.merge(A[i]-1, B[i]-1);
    cout << d.groups().size() - 1 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 9128
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map( str => parseInt(str, 10) );
    let num = 0;
    for(var i=0;i<N;i++){
        num+=A[i];
    }
    let ans = Infinity;
    let mem = 0;
    for(var i=0;i<N-1;i++){
        mem+=A[i];
        ans=Math.min(ans,Math.abs(num-mem*2));
    }
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 36792
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

struct Elem {
    int a, b;
    bool operator<(const Elem &e) const {
        return b > e.b;
    }
};

int N, H;
int A[100010], B[100010];

bool solve(int x) {
    int rest = H, cnt = 0;
    int dam = A[0];
    rep(i,0,min(N, x)) {
        if(dam > B[i]) break;
        if(rest < B[i]) return true;
        rest -= B[i];
        cnt++;
    }

    cnt += (rest + dam - 1) / dam;
    return cnt <= x;
}
 
signed main() {
    cin >> N >> H;
    rep(i,0,N) {
        cin >> A[i] >> B[i];
    }
    sort(A, A+N, greater<int>());
    sort(B, B+N, greater<int>());

    int ub = INF, lb = -1;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(solve(mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define INT(n) int n;scanf("%d",&n);
#define LL(n) long long n;scanf("%lld",&n);
#define pint(n) printf("%d",n);
#define pll(n) printf("%lld",n);
#define psp printf(" ");
#define pln puts("");
 
int main(){
        INT(H)
        INT(W)
        INT(N)
        int a[N];
        rep(i,N){
                scanf("%d",a+i);
        }
        int map[H][W];
        int dum = 0;
        int x = 0;
 
        rep(i,H*W){
                int w = i%W;
                int h = (i-w)/W;
                if (h % 2 == 0){
                        map[h][w] = x+1;
                }
                if (h%2 == 1){
                        map[h][W-w-1] = x+1;
                }
                dum ++;
                if (dum == a[x]){
                        dum = 0;
                        x ++;
                }
        }
 
        rep(i,H){
                rep(j,W){
                        pint(map[i][j]);
                       psp
                }
                pln
        }
        return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
int n,i,x,y,sum = 0;
int d[100] = {};
scanf ("%d",&n);
for (i = n;i > 0;i--)
{
    scanf("%d",&d[i]);
}
for (x = 1;x < n;x++)
{
    for (y = n;y > x;y--)
    {
       sum += (d[x]*d[y]);
    }
}
printf("%d",sum);
return 0;
}

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

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

int main(void) {
	int n,i,j,c=0;
	cin >> n;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
	}

	rep(i, n) {
		if (h[i] == 0)continue;
		for (j = i; j < n && h[j]>0; j++) {
			h[j]--;
		}
		c++;
		if (h[i] > 0)i--;
	}
	cout << c << endl;
	return 0;
}

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




//-----------------------------------------------------------------
#define rrep(i,a,b) for(int i=a;i>=b;i--)
vector<int> mul9(vector<int> s) {
	int n = s.size(), carry = 0;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] * 9 + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}
vector<int> add(vector<int> s, int x) {
	int n = s.size(), carry = x;
	vector<int> ret;
	rrep(i, n - 1, 0) {
		int c = s[i] + carry;
		carry = c / 10;
		c %= 10;
		ret.push_back(c);
	}
	while (0 < carry) {
		ret.push_back(carry % 10);
		carry /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}
//-----------------------------------------------------------------
vector<int> N;
bool chk(int k) {
	auto n = add(mul9(N), k);
	int cnt = 0;
	for (int c : n) cnt += c;

	return cnt <= k;
}
//-----------------------------------------------------------------
int main() {
	string s; cin >> s;
	for (char c : s) N.push_back(c - '0');

	int lo = 0, hi = 4501010;
	while (lo + 1 != hi) {
		int mi = (lo + hi) / 2;
		if (chk(mi)) hi = mi;
		else lo = mi;
	}
	int ans = hi / 9;
	if (hi % 9) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 10956
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z), d, ans;
    for(int i = 0; i < x; i++){
        cin >> a[i];
    }
    for(int i = 0; i < y; i++){
        cin >> b[i];
    }
    for(int i = 0; i < z; i++){
        cin >> c[i];
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            d.push_back(a[i] + b[j]);
        }
    }
    sort(rbegin(d), rend(d));
    int t = min(k, x * y);
    for(int i = 0; i < t; i++){
        for(int j = 0; j < z; j++){
            ans.push_back(d[i] + c[j]);
        }
    }
    sort(rbegin(ans), rend(ans));
    for(int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 42856
//circle
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string ss = Console.ReadLine();
            string[] s = new string[n];
            for(int i=0; i<n; i++)
            {
                s[i] = ss.Substring(i, 1);
            }
            if (n % 2 == 1)
            {
                //奇数なら繰り返しは絶対ない
                Console.WriteLine("No");
            }
            else
            {
                //偶数の時
                int restart = n / 2;
                bool flag = true;
                for(int i=0; i<restart; i++)
                {
                    if (s[i] != s[restart + i])
                    {
                        //繰り返しじゃないとき
                        Console.WriteLine("No");
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    Console.WriteLine("Yes");
                }
            }
        }

    }
}

Measured memory_bytes: 13140
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, k, c = map(int, input().split())
    def sub(s):
        n = len(s)
        cur = 0
        last = -(c + 1)
        res = [0] * (n + 1)
        for i in range(n):
            if (i - last > c and s[i] == "o"):
                cur += 1
                last = i
            res[i + 1] = cur
        return res
    
    s = input()
    left = sub(s)
    t = s
    t = t[::-1]
    right = sub(t)
    for i in range(n):
        if s[i] == "x": continue
        if left[i] + right[n - i - 1] < k:
            print(i+1)

if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 42972
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;
constexpr ll X_I_MAX = 1000000000;
constexpr ll A_MAX = 1000000000;
constexpr ll B_MAX = 1000000000;

ll N, A, B;
ll X[N_MAX];

void input() {
	scanf("%lld%lld%lld", &N, &A, &B);
	rep(i, N) scanf("%lld", X + i);
}

void solve() {
	ll ans = 0;
	repeq(i,N-1){
		ll t=(X[i]-X[i-1])*A;
		ans+=min(t,B);
	}
	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


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

using namespace std;

const int N = 1e2 + 5;
int _w;

int n , m , f[N][N][2][2] , flag;
long long ans;
char str[N];

int main( void ) {
  _w = scanf("%s%d",str+1,&m);
  n = strlen( str + 1 );
  if( str[1] != str[n] || m == 1 ) {
    for( int i = 1 , r ; i <= n ; i = r + 1 ) {
      r = i;
      while( r < n && str[r + 1] == str[i] ) ++r;
      ans += ( r - i + 1 ) / 2;
    }
    cout << ans * m;
    return 0;
  }
  flag = 1;
  for( int i = 2 ; i <= n ; ++i ) if( str[i] != str[i - 1] ) flag = 0;
  if( flag ) return printf("%lld",1LL*n*m/2),0;
  for( int i = 1 , r ; i <= n ; i = r + 1 ) {
    r = i;
    while( r < n && str[r + 1] == str[i] ) ++r;
    if( i != 1 && r != n ) ans += 1LL * ( ( r - i + 1 ) / 2 ) * m;
  }
  int l = 1 , r = n;
  while( str[l + 1] == str[1] ) ++l;
  while( str[r - 1] == str[n] ) --r;
  ans += 1LL * ( m - 1 ) * ( ( l + ( n - r + 1 ) ) / 2 );
  ans += l / 2 + ( n - r + 1 ) / 2;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void run(void){
  char s[13];
  scanf("%s",s);
  int i;
  for(i=0;i<12;i++){
    if(i==4) putchar(' ');
    putchar(s[i]);
  }
  putchar('\n');
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
/*input
ULURU
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair


using namespace std;
using namespace std::chrono;


signed main(){
    string s;
    cin>>s;
    for(int i=0;s[i];i++){
        if(s[i]=='U' || s[i]=='D')  continue;
        if((i%2==0 && s[i]=='R')||(i%2==1 && s[i]=='L')) continue;
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] + a[1] << endl;

  return 0;
}


Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    long ud;
    long cnt = 1;
    foreach (i; 1 .. n)
    {
        if (ud == 0)
        {
            if (a[i] > a[i-1]) ud = 1;
            if (a[i] < a[i-1]) ud = -1;
        }
        else
        {
            if (ud == 1 && a[i] < a[i-1])
            {
                ud = 0;
                ++cnt;
            }
            if (ud == -1 && a[i] > a[i-1])
            {
                ud = 0;
                ++cnt;
            }
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4220
#include<stdio.h>

int main(void)
{
   int a,b,d,r;
   
   double f;

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

   d=a/b;

   r=a%b;

   f=(double)a/b;

   printf("%d %d %lf",d,r,f);

   return 0;
  
}

Measured memory_bytes: 636
n=int(input())
b=list(map(int,input().split()))
a=[]

a.append(b[0])
for i in range(1,n-1) :
  if b[i-1] < b[i] :
    a.append(b[i-1])
  else :
    a.append(b[i])
a.append(b[n-2])  
print(sum(a))

Measured memory_bytes: 9096