akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, a, b, k, c;
vector<int> ans;
int main(){
    cin >> n >> a >> b;
    if (a+b>n+1 || n>1LL*a*b){
        cout << -1;
        return 0;
    }
    k=a; c=n;
    for (int l=b; l-b+1<=n; l+=b){
        --k;
        //remaining must be >=k
        if (c-(min(n, l)-(l-b))<k){
            for (int l2=n-k; l2>l-b; --l2) ans.pb(l2);
            for(int l2=n-k+1; l2<=n; ++l2) ans.pb(l2);
            break;
        }
        c-=b;
        for(int l2=min(n, l); l2>l-b; --l2) ans.pb(l2);
    }
    fox(l, ans.size()) cout << ans[l] << ' ';
    return 0;
}


Measured memory_bytes: 3440
#include <cstdio>
int main()
{
	int a,b,c;
	scanf ("%d%d%d",&a,&b,&c);
	if (a==b+c||b==a+c||c==a+b)
	 printf ("Yes\n");
	else
	 printf ("No\n");
	
return 0;
}

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

int st[10];

int main()
{
	int stn = 0;
	while(1)
	{
		int n;
		if(EOF == scanf("%d",&n))
		{
			break;
		}
		if(n == 0)
		{
			stn--;
			printf("%d\n",st[stn]);
		}
		else
		{
			st[stn] = n;
			stn++;
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << n / x * t << endl;
    }
    else {
        cout << (n / x + 1) * t << endl;
    }
}

Measured memory_bytes: 3612
def main():
    import sys
    asa =  sys.stdin.readline
    n = int(input())
    s = list(map(int, asa().split()))
    q = int(input())
    t = list(map(int, asa().split()))
    
    c = 0
    s.append(0)
    
    for i in t: # tの中のiを探索
        j = 0
        s[n] = i
        while s[j] != i:
            j += 1
        if j < n:
            c += 1
            
    print(c)
        
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 6596
N = int(input())
U = []
for i in range(N):
    U.append(input())
M = int(input())
T = []
for i in range(M):
    T.append(input())
open = False

for t in T:
    if t in U:
        if not open:
            print("Opened by " + t)
        else:
            print("Closed by " + t)
        open = not open
    else:
        print("Unknown " + t)


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

int main() {
  const double BTC = 380000.0;

  int N;
  cin >> N;

  double sum = 0;
  for (int i = 0; i < N; i++ ) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      sum += x;
    } else {
      sum += x * BTC;
    }
  }

  cout << fixed << setprecision(5) << sum << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << ((a + b)+1) / 2;
}

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

int main() {

    int N,W;
    cin >> N >> W;
    vector<int> dp(W+1,0);
    
    for(int i=0; i<N; i++) {
	int v,w,m;
	cin >> v >> w >> m;

	for(int k=0; m>0; k++) {
	    int num = min(m, (1<<k));
	    m -= num;
	    for(int j=W; j >= num*w; j--) 
		dp[j] = max(dp[j], dp[j-num*w] + num*v);
	}
    }

    int ans = 0;
    for(int x : dp) ans = max(ans,x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T;
    cin >> S >> T;

    cout << T << S << endl;

    return 0;
}

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


int main(){
  int x,y;
  cin >> x >> y;
  vector<int>  a = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a.at(x) ==a.at(y)){
    cout << "Yes" << endl;
  }
  else{
    cout <<"No" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}

static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long ExtGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (ExtGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static private long ModInverseInner(long a, long dummy1 = 0, long dummy2 = 0) => ExtGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);
    static public long ModInverse(long a) => ModInverseInner(a, 0, 0);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        string input = Console.ReadLine();

        bool isConfort = true;

        for(int i = 0; i < input.Length; i++)
        {
            if (i % 2 == 0)
            {
                //奇数番目
                char[] xxx = { 'R', 'U', 'D' };
                if (xxx.Contains(input[i]) == false)
                {
                    isConfort = false;
                    break;
                }
            }
            if (i % 2 == 1)
            {
                //偶数番目
                char[] xxx = { 'L', 'U', 'D' };
                if (xxx.Contains(input[i]) == false)
                {
                    isConfort = false;
                    break;
                }
            }
        }

        Console.WriteLine(isConfort ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    const long long MOD = 1e9 + 7;

    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<bool> bad(n + 1, false);
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        if (x <= n) {
            bad[x] = true;
        }
    }
    vector<long long> dp(n + 1, 0);
    dp[0] = 1;

    for (int i = 0; i < n; ++i) {
        if (bad[i]) {
            continue;
        }
        for (int j = 1; j <= 2; ++j) {
            int ni = i + j;
            if (ni <= n && !bad[ni]) {
                (dp[ni] += dp[i]) %= MOD;
            }
        }
    }
    cout << dp[n] << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "<";
	}
	else if (a > b) {
		cout << ">";
	}
	else {
		cout << "=";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll N,K;cin>>N>>K;
    vector<ll>V(N);for(ll i=0;i<N;i++)cin>>V[i];
    sort(V.begin(),V.end());
    ll ans=10000000000;
    for(ll i=0;i+K-1<N;i++){
        if(ans>V[i+K-1]-V[i])ans=V[i+K-1]-V[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vector<pair<int, int>> a(N);
    REP(i, N) {
        cin >> A;
        a[i] = {A, i};
    }
    sort(ALL(a));
    REP(i, N) {
        cout << a[i].second + 1 << " ";
    }
}

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

int main() {
  int N,l,r;
  int sum = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
      sum += r-l+1;
  }
        cout << sum << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
    }
    if (st.size() < n) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 10368
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = (int) 1e9 + 7;
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  return true;
}

void solve() {
  int res = 1;
  for (int p = 2; p <= n; p++) {
    {
      bool bad = false;
      for (int d = 2; d * d <= p; d++) {
        if (!(p % d)) {
          bad = true;
          break;
        }
      }
      if (bad) {
        continue;
      }
    }
    int k = 0;
    int pp = p;
    while (n / pp) {
      k += n / pp;
      pp *= p;
    }
    res = (long long) res * (k + 1) % mod;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a,b,c;
	int i,d,r;

	r=0;
 
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
	
	d=c%i;
	if(d==0)r=r+1;
	}	
	
	printf("%d\n",r);

	return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N, M;
    cin >> N >> M;
    if (N > 1) N = N - 2;
    if (M > 1) M = M - 2;
    cout << (ll)N * M << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<long long> x(n + 1);
  for (int i = 0; i < n + 1; i++)
    cin >> x[i];
  vector<long long> y(n);
  sort(x.begin(), x.end());
  for (int i = 0; i < n; i++)
    y[i] = x[i + 1] - x[i];
  long long ans = y[0];
  for (int i = 1; i < n; i++)
    ans = gcd(ans, y[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,x[maxn];
int calc(int l,int r){
	if(x[l] >= 0) return x[r];
	if(x[r] <= 0) return -x[l];
	return min(-x[l],x[r]) + x[r] - x[l];
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	int ans = inf;
	for(int i=1;i<=n - k + 1;i++){
		ans = min(ans,calc(i,i + k - 1));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int X, A, B;
	cin >> X >> A >> B;
	X -= A + B;
	cout << X % B << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int W,H,C;
  cin >> W >> H >> C;
  set<int> seW,seH;
  for(int i=1; i<=W; i++){
    if(W%i==0){
      seW.insert(i);
    }
  }
  for(int i=1; i<=H; i++){
    if(H%i==0){
      seH.insert(i);
    }
  }
  ll ans = 1;
  for(auto w: seW){
    if(seH.count(w)){
      ans = w;
    }
  }
  cout << (H/ans)*(W/ans)*C << endl;
  return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    	/*Scanner = テキスト入力を扱うためのクラス
		 *キーボードからの入力を受けつける場合は
		 *System.inを使って下記のように記述
		 */
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		//int型の配列を作成。
		//データ型[] 変数名 = new データ型[サイズ]
		int[] a = new int[n];
		int i;

		//for文で回す。a[i]番目に入力した値を順番に入れる。
		for(i=0; i<n; i++){
			a[i] =scan.nextInt();
			//System.out.println(a[i] + "番目" + " " + a[i] +" ");
		}
		/*順番入れ替えfor文。先ほどのfor文で値がiに入ってるので
		 * こちらではiの指定を行わない。
		 * 配列はa[0]から始まってるのでi-1を行い一番後ろを取り出し表示。
		 */
		for(; i>0; i--){
			System.out.print(a[i-1]);
			if(i-1 != 0) System.out.print(" ");
			else System.out.println();

		}
    }
}

Measured memory_bytes: 19648
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n,d,x;
    int a[101];
    cin >> n;
    cin >> d >> x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=(int)ceil((double)d/(double)a[i]);
    }
    cout << x+sum << endl;
    return 0;
}

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

struct shop{
  ll a,b;
};

bool asc(const shop& l,const shop& r){
  return l.a==r.a?l.b<r.b:l.a<r.a;
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<shop> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i].a>>v[i].b;
  }
  sort(v.begin(),v.end(),asc);
  ll ans=0;
  for(int i=0;i<n;i++){
    //cout<<v[i].a<<" "<<v[i].b<<endl;
    if(m>v[i].b){
      ans+=v[i].a*(v[i].b);
      m-=v[i].b;
    }else{
      ans+=v[i].a*m;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4828
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x = ni()
    d = x
    ans = 1
    for i in range(2, 33):
        j = 2
        while pow(i, j) <= x:
            if d > x - pow(i, j):
                ans = pow(i, j)
                d = x - pow(i, j)
            j += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include<stdio.h>
    
int main(){
    
int a,b,c,x;
    
scanf("%d %d %d",&a,&b,&c);
  
if(a > b){
x=a;
a=b;
b=x;
}
if(a > c){
x=a;
a=c;
c=x;
}
if(b > c){
x=b;
b=c;
c=x;
}
printf("%d %d %d\n",a,b,c);
    
return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *p,const void *q)
{
    return *(int *)p - *(int *)q;
}

int main()
{
    int n,ans;
    int d[100010];
    int i,half,board1,board2;
    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
        scanf("%d",d+i);
    }
    qsort(d,n,sizeof(int),cmp1);
    half=n/2;
    board1=d[half-1];
    board2=d[half];
    ans=board2-board1;

    printf("%d",ans);
}



Measured memory_bytes: 892
def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()

    from heapq import heappush, heappop 

    running = [] # 止まりうる座標
    events = [] # 時刻順のイベント
    finished = set() # 工事が終了した座標

    n, q = map(int, input().split())
    for _ in range(n):
        s, t, x = map(int, input().split())
        events.append((s - x, x, 1)) # 追加イベント
        events.append((t - x, x, 0)) # 削除イベント
    for _ in range(q):
        d = int(input())
        events.append((d, 10**10, 2)) # 出発イベント,同じ時刻内で最後になるよう第二引数設定
    events.sort()
    for i in range(len(events)):
        temp = events[i]
        if temp[-1] == 1:
            heappush(running, temp[1])
            finished.discard(temp[1])
        elif temp[-1] == 0:
            finished.add(temp[1])
        else:
            flag = 1
            while running:
                p = heappop(running)
                if p not in finished:
                    flag = 0
                    heappush(running, p)
                    print(p)
                    break
            if flag:
                print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 91712
#define _CRT_SECURE_NO_WARNINGS

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



using namespace std;

typedef long long int ll;

#define REP(i,n) for(int i=0; i<(n); ++i )
#define REPR(i,n) for(int i=(n); i>=0; --i)
#define FOR(i,a,n) for(int i=(a); i<(n); ++i )
#define FORR(i,a,n) for(int i=(n); i>=(a); --i)

#define VDOUT(x) cerr << #x << "\n";for(auto i : x ) cerr << "  " << i << "\n";
#define DOUT(x) cerr << #x << " = " << x << "\n";

#define COUT(x) cout << (x) << "\n";
#define COUT2(x,y) cout << (x) << " " << (y) << "\n";
#define COUT3(x,y,z) cout << (x) << " " << (y) << " " << (z) << "\n"; 

#define INI ios::sync_with_stdio(false);cin.tie(0)


#define ALL(x) x.begin(),x.end()


signed main()
{
	INI;
	int a, b;
	cin >> a >> b;
	COUT((a + b) % 24);
	return 0;
}





Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
		Arrays.sort(array);
		System.out.println(array[2] - array[0]);
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int m = 0;
        int f = 0;
        int r = 0;
        int i = 0;
        int j = 0;
        int k = 0;
        
        int stu[][] = new int[50][3];
        int goukei[] = new int[50];
        
        while(true){
            for(j=0; j<3 ;j++){
                stu[i][j] = sc.nextInt();
                if(j<2){
                    goukei[i] = goukei[i]+stu[i][j];
                }
            }
            if(i==49 || (stu[i][0]==-1 && stu[i][1]==-1 && stu[i][2]==-1 ))break;
            i++;
        }
        
        for(i=0;i<50;i++){
            if(stu[i][0] == -1 && stu[i][1] == -1 && stu[i][2] == -1)break;
            if(stu[i][0] == -1 || stu[i][1]==-1 ){
                System.out.println("F");
            }else if(80<=goukei[i]){
                System.out.println("A");
            }else if(65 <= goukei[i] && goukei[i]<80){
                System.out.println("B");
            }else if(50 <= goukei[i] && goukei[i]<65 || 50 <= stu[i][2]){
                System.out.println("C");
            }else if(30 <= goukei[i] && goukei[i]<50){
                System.out.println("D");
            }else if(goukei[i]<30){
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26384
n,a,b =map(int,input().split())
s = input()
cnt = 0
p = 0
for i in range(n):
    if s[i] == 'a':
        if cnt <a+b:
            print('Yes')
            cnt +=1
        else:
            print('No')
    elif s[i] == 'b':
        p +=1
        if cnt <a+b and p <=b:
            print('Yes')
            cnt +=1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9244
def bubbleSort(cards):
    for i, _ in enumerate(cards):
        for j in range(len(cards) -1, i, -1):
            if int(cards[j][1]) <  int(cards[j-1][1]):
                cards[j], cards[j - 1] = cards[j - 1], cards[j]
    return cards
    
def selectionSort(cards):
    for i in range(len(cards)):
        min_j = i
        for j in range(i, len(cards)):
            if int(cards[j][1]) < int(cards[min_j][1]):
                min_j = j
        cards[i], cards[min_j] = cards[min_j], cards[i]
    return cards
    
N = int(input())
A = input().split()

temp = A.copy()
bs = bubbleSort(temp)

temp = A.copy()
ss = selectionSort(temp)

print(' '.join(bs))
print('Stable')
print(' '.join(ss))
if [a[:1] for a in bs] == [a[:1] for a in ss]:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  int k;
  string s;
  cin >> k >> s;
  if(k >= s.size()){
    cout << s << endl;
    return 0;
  }else{
    cout << s.substr(0,k) << "..." << endl;
    return 0;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> grid(h,vector<char>(w));
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            cin >> grid[i][j];
            if(grid[i][j]=='#') cnt++;
        }
    }
    debug(cnt);
    int ans = 0;
    for(int bit1 = 0;bit1 < (1<<h);bit1++){
        for(int bit2 = 0;bit2 < (1<<w);bit2++){
            bitset<6> yoko(bit1), tate(bit2);
            int kesu = 0;
            rep(i,h){
                if(!yoko.test(i)) continue;
                rep(j,w){
                    if(grid[i][j]=='#') kesu++;
                }
                rep(k,w){
                    if(!tate.test(k)) continue;
                    if(grid[i][k]=='#') kesu--;
                }
            }
            rep(i,w){
                if(tate.test(i) == 0) continue;
                rep(j,h){
                    if(grid[j][i]=='#') kesu++;
                }
            }
            if(cnt-kesu==k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
//
// Created by Hideaki Imamura on 2020-03-11.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (INT_MAX)
# define PI (acos(-1))
//const ll mod = 1000000007;

// 桁数は0-indexedとする
// dp[0][i]: i-1桁目まで見たとき、i-1桁目をぴったり払った時、必要なお札最小枚数
// dp[1][i]: i-1桁目まで見たとき、i-1桁目をお釣りもらって払った時、必要なお札最小枚数
ll dp[2][1000010];
string S;

int main() {
    cin >> S;
    reverse(S.begin(), S.end());
    S += '0';

    for (int i = 0; i <= S.size(); ++i) {
        dp[0][i] = dp[1][i] = INF;
    }
    dp[0][0] = 0;

    for (int i = 0; i < S.size(); ++i) {
        for (int j = 0; j < 2; ++j) {
            int x = S[i] - '0';
            x += j;
            if (x < 10) chmin(dp[0][i+1], dp[j][i] + x);
            if (x > 0) chmin(dp[1][i+1], dp[j][i] + 10 - x);
        }
    }
    cout << dp[0][S.size()] << endl;
    return 0;
}

Measured memory_bytes: 17028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
/*
int c = (int)(S[i] - '0');
AA.push_back(c);
*/
using namespace std;
long L,R;

void dfs(long A,long B,vector<long> &K)
{
	if(A==R&&B==R)
	{
		return;
	}
	if(B<R)
	{
		if(A<B)
		{
			K.push_back(A*B%2019);
			if(A*B%2019==0){return;}
		}
		dfs(A,B+1,K);
	}
	if(B==R)
	{
		if(A<B)
		{
			K.push_back(A*B%2019);
			if(A*B%2019==0){return;}
		}
		B=L;
		dfs(A+1,B,K);
	}
}

int main()
{
	vector<long> T;
	cin >> L >> R;
	dfs(L,L,T);
	sort(T.begin(),T.end());
	cout << T.front() << endl;
}

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

using namespace std;

int n;
long long a, b, c, d, x[2], y[2];

int main() {
	scanf("%d%lld%lld%lld%lld", &n , &a, &b, &c ,&d);
	a = abs(a - b);
	n--;
	for (int i = 0; i <= n; i++) {
		x[0] = c * i;
		x[1] = d * i;
		y[0] = c * (n - i) + a;
		y[1] = d * (n - i) + a;
		if (x[0] >= y[0] && x[0] <= y[1]) {
			printf("YES\n");
			return 0;
		}
		if (x[1] >= y[0] && x[1] <= y[1]) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    while(1){
        int a[4], b[4];
        REP(i,4) if(!(cin >> a[i])) return 0;
        REP(i,4) if(!(cin >> b[i])) return 0;

        int hi = 0, bl = 0;
        REP(i,4) REP(j,4){
            if(a[i] == b[j]){
                if(i == j) hi++; else bl++;
            }
        }
        cout << hi << " " << bl << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
program sample
    implicit none
    character(1),allocatable::s(:,:)
    character(100)::t
    integer(8) :: i,j,m,n,h,w,a,b,c
    integer(8),allocatable :: x(:,:),y(:)
    read(*,*)h,w
    allocate(s(0:h+1,0:w+1))
    s(:, :)='0'
    do i=1,h
        read(*,*) t
        do j=1,w
            s(i,j)=t(j:j)
        enddo
    end do
    do i=1,h
        do j=1,w
            if(s(i,j) .eq. '#')then
                if(s(i+1,j) .eq. '#')then
                    cycle
                else if(s(i-1,j) .eq. '#')then
                    cycle
                else if(s(i,j-1) .eq. '#')then
                    cycle   
                else if(s(i,j+1) .eq. '#')then
                    cycle
                else
                    write(*,*)'No'
                    stop
                end if
            end if
        end do
    end do
    write(*,*)'Yes'

   
  
    stop
end program sample
  


  



Measured memory_bytes: 2860
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;
  long long K;
  cin >> K;

  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }

  int times = 0;
  vector<int> first_visit(N, -1);
  int loop_town;
  int now = 0;
  rep(i, N) {
    if (first_visit[now] != -1) {
      loop_town = now;
      break;
    }

    first_visit[now] = times;
    times++;
    now = a[now];
  }

  int loop_cycle = times - first_visit[loop_town];
  if (K <= first_visit[loop_town]) {
    rep(i, N) {
      if (K == first_visit[i]) {
        cout << i + 1 << endl;
        break;
      }
    }
  } else {
    K -= first_visit[loop_town];
    K %= loop_cycle;
    rep(i, N) {
      if (K == first_visit[i] - first_visit[loop_town]) {
        cout << i + 1 << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4844
import sys
sys.setrecursionlimit(10**7)
n=int(input())

g=[[] for _ in range(n+1)]
v=[0 for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
    
c=sorted([int(i) for i in input().split()])[::-1]

def bfs(x):
    p=[]
    q=[x]
    while q:
        y=q.pop()
        v[y]=1
        p.append(y)
        for nb in g[y]:
            if v[nb]!=1:
                q.append(nb)
    return p

l=bfs(1)
ans=[0]*(n)
for i in range(n):
    ans[l[i]-1]=c[i]

print(sum(c[1:]))
print(*ans)


Measured memory_bytes: 50648
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
//use std::cmp; // cmp::max,cmp::min

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

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

//////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2018&lang=jp

fn is_right(c: char) -> bool{
    let right : Vec<char> = "yuiophjklnm".chars().collect();


    match right.iter().find(|&&m| m==c){
        Some(_) => true,
        None => false,
    }
}

fn solve() -> bool{
    let s = read_charvec();

    if s[0] == '#'{
        return false;
    }

    let mut state = is_right(s[0]);
    let mut n = 0;

    for c in s.iter(){
        let now_state = is_right(*c);

        if now_state != state{
            state = now_state;
            n += 1;
        }
    }
    println!("{}",n);

    return true;
}

fn main(){
    while solve(){};
}





/*
DOCS

///////////////// Vec /////////////////

let v = vec![0;2]; // [0,0]
let sum_x = xs.iter().fold(0,|s,i|s+i); // xs : Vec<i64>

s.chars().nth(i as usize).unwrap();

let xs : Vec<i32> = read_charvec().iter().map(|&c| 
    if c == 'A'{
        0
    }else if c == 'B'{
        1
    }else if c == 'X'{
        2
    }else{
        3
    }
).collect();

// search
let i = match xs.iter().find(|&&m| m==0){
    Some(_) => true,
    None => false,
};

///////////////// HashMap /////////////////

let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}

///////////////// swap /////////////////

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);

///////////////// priority queue /////////////////

// https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html
let mut heap = BinaryHeap::new();

heap.push(1);
heap.push(5);
heap.push(2);

assert_eq!(heap.pop(), Some(5));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));
assert_eq!(heap.pop(), None);

let mut vs = heap.into_vec();
vs.reverse();

*/



Measured memory_bytes: 5048
#include <bits/stdc++.h>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define RE(i,n) FOR(i,1,n)
#define R(i,n) REP(i,n)
#define FI first
#define SE second
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
 
template<class C> void mini(C& a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C& a4, C b4) { a4 = max(a4, b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
 
template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
 
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
#define x FI
#define y SE
 
int n;
vector<PII> x;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  PII s,t;
  cin >> s.x >> s.y >> t.x >> t.y;
  bool swa = 0;
  if(s > t){
    swap(s,t);
  }
  if(s.y > t.y){
    s.y *=-1;
    t.y *=-1;
    swa = 1;
  }
  cin >> n;
  R(i,n){
    PII pom;
    cin >> pom.x >> pom.y;
    if(swa){
      pom.y *=-1;
    }
    if(pom < s || pom > t || pom.y > t.y || pom.y < s.y){
      continue;
    }
    x.PB(pom);
  }
//   if((s.x == t.x || s.y == t.y) && SZ(x)){
//     cout << ((t.x - s.x) + (t.y - s.y))*100 - 20 + 10 * M_PI << "\n";
//     return 0;
//   }
  debug(SZ(x));
  sort(ALL(x));
  vector<int> st;
  st.PB(s.y);
  for(PII el:x){
    int po = -1;
    int ko = SZ(st);
    while(po + 1 != ko){
      int m = (po + ko) / 2;
      if(st[m] <= el.y){
        po = m;
      }else{
        ko = m;
      }
    }
    debug(ko,st[0],el.y);
    if(SZ(st) == ko)st.PB(0);
    st[ko] = el.y;
  }
  debug(SZ(st)-1);
  const LD C = 5 * M_PI - 20;
  LD res = ((t.x - s.x) + (t.y - s.y)) * 100 + C * (SZ(st)-1);
  if(SZ(st) -1 > min(t.x - s.x, t.y - s.y)){
    debug(":P");
    res += 5 * M_PI;
  }
  cout << res << "\n";
}

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

 using namespace std;

 int main() {
   string s;
   int i;

   cin >> s;

   string ans;
   for (i = 0; i < s.length(); i++) {
     if (s.at(i) != 'B') {
       ans = ans + s.at(i);
     }
     else {
       if (ans.size() != 0) ans = ans.substr(0, ans.size() - 1);
     }
   }

   for (i = 0; i < ans.size(); i++) cout << ans.at(i);

   cout << endl;
 }


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int second = sc.nextInt();
		
        int h = second/3600;
        int m = (second % 3600)/60;
        int s = (second % 3600)% 60;
        
        System.out.println(h + ":" + m + ":" + s);
			
		}

}

Measured memory_bytes: 26056
/* ************************************************************* */
/*     Author     : Mahabub.Tweety                               */
/*     Email      : mahabubrahman618@gmail.com                   */
/*     University : Comilla University, Bangladesh		         */
/*                  Department of Computer Science & Engineering */
/* ***************************************************************

/*
	Compiled : CNU c++ 14
	Copyright 2019 by Mahabub Rahman & Comilla University Sailor ; all rights reserved.
	Permission is granted for use in non-commercial applications provided this
	copyright notice remains intact   and unchanged.
*/


/*...................................Data_Types............................................*/

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<list>
#include<iterator>
#include<math.h>

using namespace std;

#define       ll                  long long int
#define       ull                  unsigned long long int
#define       veci                 vector<int>
#define       vecc                 vector<char>
#define       vecs                 vector<string>
#define       vecl                 vector<long long int>
#define       vecp                 vector<  pair<int,int> >
#define       mapstrint            map< string , int >
#define       mapstrstr            map< string , string >
#define       mapint               map< int, int >
#define       pb                   push_back
#define       pob                  pop_back
////============ CONSTANT ===============////
#define mx7   10000007
#define mx6   1000006
#define mx5   100005
#define inf   1<<30                                           //infinity value
#define eps   1e-9
#define mx    (65540)
#define mod   1000000007
////=====================================////

long double PI = acosl(-1);
bool myfunc(int a, int b) //This function is use for descending order.
{
    return (a>b);
}
ll fact(ll n)
{
    if(n==0 || n==1) return 1;
    else return n*fact(n-1);
}

////======================================////

int main()
{
    int a, p;
    cin >> a >> p;
    int t = (a*3)+p;
    cout << t/2 << endl;

    return 0;
}


Measured memory_bytes: 256
seen = set()

N = int(input())

prev = ""
for i in range(N):
    w = input()
    if w in seen:
        print("No")
        exit()
    seen.add(w)
    if i == 0:
        prev = w[-1]
        continue
    if prev != w[0]:
        print("No")
        exit()
    prev = w[-1]
print("Yes")


Measured memory_bytes: 62476