akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b) = scan!(usize, usize, usize);
    let vs = scan!(usize;;);
    let mut ans = 0;
    for (v0, v1) in vs.iter().zip(vs[1..].iter()) {
        let walk = (v1 - v0) * a;
        if walk < b {
            ans += walk
        } else {
            ans += b
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 6396
n,y = map(int, input().split())

out = ''
for i in range(n+1):
  if out != '':
    break
  if i * 10000 > y:
    break
  for j in range(n-i+1):
    if i*10000+j*5000+(n-i-j)*1000 == y:
      out = '{} {} {}'.format(i,j,n-i-j)

if out == '':
  out = '-1 -1 -1'
print(out)

Measured memory_bytes: 3060
using namespace std;

#include <iostream>
#include <stdlib.h>
#include <string.h>

using QWORD = unsigned long long;
using SDWORD = int;
using DWORD = unsigned int;
using KNAPSACK_OBJ_ST = struct
{
    QWORD dwWeight;
    QWORD dwValue;
};

int main()
{
    DWORD dwInput_N;
    DWORD dwInput_K;
    char str[30];

    cin.getline(str, sizeof(str));
    dwInput_N = atoi(strtok(str, " "));
    dwInput_K = atoi(strtok(NULL, " "));

    // printf("n:%d k:%d\n", dwInput_N, dwInput_K);
    QWORD qwAnswer = 0;
    if (0 == dwInput_K % 2) {
        QWORD qwAnswer1, qwAnswer2;
        DWORD dwUnit1 = (dwInput_N / dwInput_K);
        qwAnswer1 = (QWORD)dwUnit1 * (QWORD)dwUnit1 * (QWORD)dwUnit1;

        DWORD dwUnit2 = (dwInput_N + (dwInput_K / 2)) / dwInput_K;
        qwAnswer2 = (QWORD)dwUnit2 * (QWORD)dwUnit2 * (QWORD)dwUnit2;

        //printf("%d %d\n", dwAnswer1, dwAnswer2);

        qwAnswer = qwAnswer1 + qwAnswer2;
    } else {
        DWORD dwUnit = (dwInput_N / dwInput_K);
        qwAnswer = (QWORD)dwUnit * (QWORD)dwUnit * (QWORD)dwUnit;
    }

    printf("%llu\n", qwAnswer);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, d;
	cin >> n >> d;
	if (n % (2*d+1)) cout << n / (2*d+1) + 1 << endl;
	else cout << n / (2*d+1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int l[200005],r[200005],n,k,c,cnt=0;
int main(){
    cin>>n>>k>>c;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            l[++cnt]=i;
            i+=c;
        }
        if(cnt==k) break;
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
            r[cnt--]=i;
            i-=c;
        }
        if(cnt==0) break;
    }
    for(int i=1;i<=k;i++){
        if(l[i]==r[i]){
            cout<<l[i]+1<<endl;
        }
    }
}

Measured memory_bytes: 3332
fun main(args : Array<String>) {
    val s = readLine()!!

    var lIdx = 0
    var rIdx = s.length-1
    var cnt = 0

    while (lIdx <= rIdx) {
        if (s[lIdx] == s[rIdx]) {
            lIdx++
            rIdx--
            continue
        }

        if (s[lIdx] == 'x') {
            cnt++
            lIdx++
            continue
        }

        if (s[rIdx] == 'x') {
            cnt++
            rIdx--
            continue
        }

        println(-1)
        return
    }

    println(cnt)
}

Measured memory_bytes: 36948
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;



int main(){
	int n;
	cin>>n;
	char s[n][n];
	for(int i1=0;i1<n;i1++){
		for(int i2=0;i2<n;i2++){
			cin>>s[i1][i2];
		}
	}
	int64_t ans=0;
	for(int a=0;a<n;a++){
		bool possible=true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(s[(i+a)%n][j]!=s[(j+a)%n][i]){
					possible=false;
					break;
				}
			}
		}
		if(possible){
			ans++;
		}
	}
	cout<<ans*n<<endl;

	return 0;
}



Measured memory_bytes: 384
from bisect import *
from sys import stdin, stdout
readline = stdin.readline
N, Q = map(int, readline().split())
ans = []
if N == 1:
    for q in range(Q):
        v, w = map(int, readline().split())
        ans.append(str(v))
else:
    c = 1
    B = [1]
    while c < 10**9:
        B.append(c+1)
        c = c*N + 1
    for q in range(Q):
        v, w = map(int, readline().split())
        lv = bisect(B, v)
        lw = bisect(B, w)
        if lv < lw:
            w = (w + (B[lw-lv]-1)*(N-2)) // N**(lw-lv)
        while v != w:
            v = (v + (N - 2)) // N
            w = (w + (N - 2)) // N
        ans.append(str(v))
stdout.write("\n".join(ans))
stdout.write("\n")


Measured memory_bytes: 59740
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i<=n; i++) {
        int x;
        cin >> x;
        if(i%2 == 1 && x%2 == 1) ans ++;
    }
    cout << ans << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    //Plese remember to uncomment for taking test cases.
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

int get_max(int add, int sub, int mul){
	int max = add;
	if(sub >= max){ max = sub; }
	if(mul >= max){ max = mul; }
	return max;
}

int main(){
	int A, B;
	cin >> A;
	cin >> B;

	int add = A + B;
	int sub = A - B;
	int mul = A * B;
	int max = get_max(add, sub, mul);

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
typedef pair<int, int> P;

const int INF = 1000000007;
int n, X[1005];
vector <int> edge[1005];
P dp[1005];
bool possible;

void dfs(int cur) {
    int dp2[2][X[cur]+1];
    fill(dp2[0], dp2[2], INF);
    dp2[0][0] = 0;

    int tmp = 0, nxt = 1;
    for (int i = 0; i < edge[cur].size(); i++) {
        int child = edge[cur][i];
        dfs(child);

        int x = dp[child].first;
        int y = dp[child].second;
        //cout << "cur = " << cur << " x = " << x << " y = " << y << "\n";

        for (int j = 0; j <= X[cur]; j++) {
            if (dp2[tmp][j] == INF) continue;

            if (j + x <= X[cur]) {
                dp2[nxt][j+x] = dp2[tmp][j] + y;
            }

            if (j + y <= X[cur]) {
                dp2[nxt][j+y] = dp2[tmp][j] + x;
            }
        }

        swap(tmp, nxt);
        for (int j = 0; j <= X[cur]; j++) {
            dp2[nxt][j] = INF;
        }
    }

    for (int i = X[cur]; i >= 0; i--) {
        if (dp2[tmp][i] < INF) {
            dp[cur] = P(X[cur], dp2[tmp][i]);
            return;
        }
    }

    possible = false;
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        edge[p].push_back(i);
    }

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

    possible = true;
    dfs(0);

    if (possible) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 11136
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(H: int, W: int, a: "[List[str]"):
    dp = [[0] * (W+1) for i in range(H+1)]

    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            
            if 0 <= i < H and 0 <= j+1 < W and a[i][j+1] == '.':
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD
            if 0 <= i+1 < H and 0 <= j < W and a[i+1][j] == '.':
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD


    print(dp[H-1][W-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ next(tokens) for _ in range(H) ]  # type: "List[List[str]]"
    solve(H, W, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52848
#include <bits/stdc++.h>
using namespace std;
#define pii             pair <int, int>
#define ff              first
#define ss              second
#define eps             1e-10
#define LL              long long
#define pb              push_back
#define mk              make_pair
#define inf             0x3f3f3f3f
#define vi              vector <int>
#define all(a)          a.begin(), a.end()
#define Unique(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define MAX             256
#define ULL             unsigned long long

const int N = 2000006;
const int MOD = 1e9 + 7;

int in[N];
int res[N];

void ans_me(int ix) {
    if(ix == 5) {
        int sm = 0;
        for(int i = 0; i < 4; i++) sm += res[i];
        if(sm == 7) {
            for(int i = 0; i < 4; i++) {
                if(!i) cout << res[i];
                else {
                    if(res[i] < 0) cout << '-';
                    else cout << '+';
                    cout << abs(res[i]);
                }
            }
            cout << "=7\n";
            exit(0);
        }
        return ;
    }

    if(ix) {
        res[ix] = in[ix];
        ans_me(ix + 1);
        res[ix] = -in[ix];
        ans_me(ix + 1);
    }
    else {
        res[ix] = in[ix];
        ans_me(ix + 1);
    }
}

int main()
{
    string s; cin >> s;
    for(int i = 0; i < 4; i++) in[i] = s[i] - '0';
    ans_me(0);
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

//要素数n個分入力を行う
void input_vector( vector<int> &v, int n)
{
	int tmp;

	for(int i = 0; i < n; i++)
	{
		cin >> tmp;
		v.push_back(tmp);
	}
}

//ミンコフスキー距離を計算
double calc_minkovski(int p, int n, const vector<int> &vx, const vector<int> &vy)
{
	double distance;
	double power;
	double sum = 0;

	if( p != 0)
	{
		power = (double)1 / p;

		for(int i = 0; i < n; i++)
		{
			sum += pow( abs(vx[i] - vy[i]), p);
		}
		distance = pow(sum, power);
	}
	else	//p = 0の時，p = ∞として計算
	{
		double dist_max = 0;
		double tmp;
		for(int i = 0; i < n; i++)
		{
			tmp = abs(vx[i] - vy[i]);

			if(tmp > dist_max)
			{
				dist_max = tmp;
			}
		}
		distance = dist_max;
	}

	return distance;
}

int main(void)
{
	int n;					//ベクトルの要素数
	double dist_manhattan;	//マンハッタン距離(p = 1)
	double dist_euclid;		//ユークリッド距離(p = 2)
	double dist_chebyshev;	//チェビシェフ距離(p = ∞)
	double dist_p3;			//p = 3の時のミンコフスキー距離

	vector<int> x;			//ベクトルx
	vector<int> y;			//ベクトルy

	cin >> n;	//要素数を入力

	//要素を入力
	input_vector(x, n);
	input_vector(y, n);

	//各ミンコフスキー距離を求める
	dist_manhattan = calc_minkovski(1, n, x, y);
	dist_euclid = calc_minkovski(2, n, x, y);
	dist_p3= calc_minkovski(3, n, x, y);
	dist_chebyshev = calc_minkovski(0, n, x, y);


	//計算結果出力
	cout << fixed << setprecision(12);
	cout << dist_manhattan << endl;
	cout << dist_euclid << endl;
	cout << dist_p3 << endl;
	cout << dist_chebyshev << endl;
	
	return 0;
}



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

#point = [k for i in range(n)]
tmp = [0 for i in range(n)]
for i in range(q):
    answer = int(input())
    tmp[answer-1] += 1

for i in range(n):
    if k - (q - tmp[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4672
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
s, t = read().decode().split()

ans = 2 * N
for i in range(N + 1):
    if s[-i:] == t[:i]:
        ans = 2 * N - i

print(ans)


Measured memory_bytes: 2940
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] a = new int [n];
      	for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
        }
      	Arrays.sort(a);
      	System.out.println(a[n-1]-a[0]);
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int R, G, B, N; cin >> R >> G >> B >> N;
  ll ans = 0;
  int loop = 3000;
  for(int i = 0; i <= loop; ++i) {
    if(R * i > N) break;
    for(int k = 0; k <= loop; ++k) {
      if(R * i + G * k > N) break;
      ll tmp = R * i + G * k;
      if((N - tmp) % B == 0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace NTL_1_B_Power
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] input = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			var result = Power (input[0], input[1], 1000000007);
			Console.WriteLine (result);
		}

		static long Power ( long num, long power, long mod )
		{
			long result = 1L;

			while (0 < power)
			{
				if ((power & 1) != 0)
				{
					result = result * num % mod;
				}

				num = num * num % mod;
				power >>= 1;
			}

			return result;
		}
	}
}



Measured memory_bytes: 9188
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

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

#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    string s;
    cin>>s;

    lli a[4];
    lli i;

    rep(i,0,4)
    {
        a[i]=s[i]-'0';
    }

    if(a[0]-a[1]-a[2]-a[3] == 7)
    {
        cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]-a[1]-a[2]+a[3] == 7)
    {
        cout<<a[0]<<'-'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]-a[1]+a[2]-a[3] == 7)
    {
        cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]-a[1]+a[2]+a[3] == 7)
    {
        cout<<a[0]<<'-'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]+a[1]-a[2]-a[3] == 7)
    {
        cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'-'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]+a[1]-a[2]+a[3] == 7)
    {
        cout<<a[0]<<'+'<<a[1]<<'-'<<a[2]<<'+'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]+a[1]+a[2]-a[3] == 7)
    {
        cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'-'<<a[3]<<'='<<7;
        exit(0);
    }

    if(a[0]+a[1]+a[2]+a[3] == 7)
    {
        cout<<a[0]<<'+'<<a[1]<<'+'<<a[2]<<'+'<<a[3]<<'='<<7;
        exit(0);
    }





 return 0;
}


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

using namespace std;

vector<int> vi;
#define _for(i,j,N) for(int i = (j); i < (N);i++)

int main()
{
    vi.push_back(0);
    int N;
    scanf("%d",&N);
    _for(i,0,N){
        int a;scanf("%d",&a);
        vi.push_back(a);
    }
    vi.push_back(0);
    int sum = 0;
    _for(i,1,vi.size()){
        sum += abs(vi[i]-vi[i-1]);
    }
    _for(i,1,vi.size()-1){
        int bef = abs(vi[i]-vi[i-1]) + abs(vi[i+1] - vi[i]);
        int after = abs(vi[i+1] - vi[i-1]);
        printf("%d\n",sum-bef+after);
    }

    return 0;
}


Measured memory_bytes: 1784
#include<cstdio>
int a[100005];
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  int ans=0;
  for(int i=1;i<=n;++i)ans+=(a[a[i]]==i);
  printf("%d\n",ans/2);
  return 0;
}


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

string S;

int main() {
    cin >> S;

    char prev = S[0];
    int cnt = 0;
    for (int i = 1; i < S.length(); ++i) {
        if (prev != S[i]) {
            ++cnt;
            prev = S[i];
        }
    }

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

Measured memory_bytes: 512
using System;

namespace AtCoder {
    class Program {
        static void Main() {
            const long magic_num = 1000000007;

            string input = Console.ReadLine();

            int count = int.Parse(input);

            long sum = 1;
            for(int i = 1; i <= count; i++) {
                sum = sum * i % magic_num;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11092
#![allow(unused_imports)]

use text_io::*;
use itertools::Itertools;

fn main() {
    let a: usize = read!();
    let mut sum: usize = 0;
    let b: Vec<usize> = a.to_string().chars().map(|a|a.to_digit(10).unwrap() as usize).collect_vec();
    for i in 0..b.len() {
        sum+=b[i];
    }
    println!("{}",if a%sum==0 {"Yes"}else{"No"})
}

Measured memory_bytes: 2156
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int n, m, x;
    int a[102];
    int max_ = 0, min_ = 0;
    cin >> n >> m >> x;
    REP(i, m){
        cin >> a[i];
    }
    REP(i, m){
        if(x > a[i]){
            max_++;
        }else{
            min_++;
        }
    }
    print(min(max_, min_));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i,sum=0;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    int ans=sum,g=0;
    for(i=0;i<n;i++){
        g+=a[i];
        sum-=a[i];
        ans = min(ans,std::abs(sum-g));
    }
    cout << ans;
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  string s;
  int k0;
  cin >> s >> k0;

  function<int (int, int, bool)> count = [&](int i, int k, bool lim) {
    if (k == 0) return 1;
    if (i == sz(s)) return 0;
    int ret = 0, cur = s[i] - '0';

    ret += count(i + 1, k, lim && cur == 0);

    if (lim) {
      if (cur != 0) {
        ret += (cur - 1) * count(i + 1, k - 1, false);
        ret += count(i + 1, k - 1, lim);
      }
    } else {
      ret += 9 * count(i + 1, k - 1, false);
    }

    // cout << i << ' ' << k << ' ' << lim << ' ' << ret << endl;
    
    return ret;
  };
  cout << count(0, k0, true);

  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(2);
    vector<uint64_t> num_vec(0);
    // string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, num2;
    uint64_t num, result;
    // uint64_t result;
    double length, mass;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    int64_t temp, temp2, read;
    int64_t i, j, k, l, count, n, x, y, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
    
    cin >> n >> x >> y;

    l=0;
    for (i = 1; i <= n-1; i++) {
        for (j = i+1; j <= n; j++) {
            temp = j - i;
            temp2 = abs(j-y) + 1 + abs(x-i);
            num_vec.push_back(MIN(temp, temp2));
            l++;
        }
    }

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

    read = 0;
    size = n * (n - 1) / 2;
    for (k=1; k<n; k++) {
        result = 0;
        for (i=0; i<size; i++) {  
            if ((read + i) >= size) {
                break;
            } else if (num_vec.at(read + i) == k) {
                result++;
            } else {
                read += i;
                break;
            }
        }
        cout << result << endl;
    }

    // cout << fixed << setprecision(10) << mass << endl;

    // for (i=0; i<num; i++) {
    //     cin >> temp_vec.at(0) >> temp_vec.at(1);
    //     arr.push_back(temp_vec);
    // }

    // for (i=0; i<num; i++) {
    //     temp = arr.at(i).at(0);
    //     result[temp] = arr.at(i).at(1);
    // }

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 18280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a*500 >= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readInt()

ex = [s]

while 1:
	if ex[-1]%2:
		ex.append(3*ex[-1]+1)
	else:
		ex.append(ex[-1]//2)
	if ex.count(ex[-1])==2:
		break

print(len(ex))

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long p, q;
    cin >> p >> q;
    q = q / __gcd(p, q);
    int q_q = q;
    int ans = 1;
    for (int i = 2; i <= q / 2; i++) {
        if (q_q % i == 0) {
            q_q /= i;
            ans *= i;
            while (q_q % i == 0) {
                q_q /= i;
            }
        }
    }
    if (ans == 1) {
        ans = q;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;

namespace CountABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int lettersAmount = int.Parse(Console.ReadLine());
            List<char> lettersInput = Console.ReadLine().ToList();

            List<string> abcSentences = new List<string>();

            int abcAmount = 0;
            for(int i = 0; i < lettersAmount; i++)
            {
                string abcString = "";

                if (lettersInput[i].ToString() == "A" && i < lettersAmount && i + 1 < lettersAmount && i + 2 < lettersAmount)
                {
                    abcString += lettersInput[i].ToString() + lettersInput[i + 1].ToString() + lettersInput[i + 2].ToString();
                }

                if(abcString == "ABC")
                {
                    abcAmount++;
                }
            }
            Console.WriteLine(abcAmount);     
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {

	string s;
	int num;
	cin >> s >> num;

	rep(i,0,s.length()){
		if (s[i]!='a' && 'z' - s[i]  < num) {
			num -= ('z' + 1) - s[i];
			s[i] = 'a';
		}
	}


	
	while ('z' - s[s.length() - 1] < num) {
			num -= ('z' + 1) - s[s.length() - 1];
			s[s.length() - 1] = 'a';
		
	}

	if(num>0)s[s.length() - 1] = s[s.length() - 1] + num;



	cout << s << endl;
	return 0;
}

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

using namespace std;

main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n - 1; ++i) if (s[i] == s[i + 1]) ans++;
    cout << min(n - 1, 2 * k + ans) << '\n';
    return 0;
}



Measured memory_bytes: 512
a, b, k=map(int, input().split())
if a+k-1>=b-k+1:
  for i in range(a, b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    lis=[]
    ans=0
    for i in range(n):
        s=input()
        s_c=Counter(s)
        s_ct=tuple(sorted(s_c.items()))
        lis.append(s_ct)
    lis_c=Counter(lis)
    for li in lis_c.items():
        x=li[1]
        if x>=2:
            ans+=x*(x-1)//2
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 138756
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	
	if(abs(a - b) > k || abs(a - c) > k || abs(a - d) > k || abs(a - e) > k || abs(b - c) > k || abs(b - d) > k || abs(b - e) > k || abs(c - d) > k || abs(c - e) > k || abs(d - e) > k){
		cout << ":(" << endl;
	}
	else cout << "Yay!" << endl;
	
	
	
	
	
	
	
	

	
	
	
	
	
    
	return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


double dist(vector <double> x, vector <double> y){
  double z;
  forll(i, 0, x.size()){
	z += pow((x[i] - y[i]), 2.0);
  }
  return sqrt(z);
}

int main()
{
  ll n, d, count;
  double t;
  cin >> n >> d;
  vector<vector <double>> x(n, vector<double>(d));
  forll(i, 0, n){
	forll(j, 0, d){
	  cin >> x[i][j];
	}
  }

  forll(i, 0, n-1){
	forll(j, i+1, n){
	  t = dist(x[i], x[j]);
	  if ((double)(int)(t) == t)
		count += 1;
	}
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b,c;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
cout<<(1900*b+(a-b)*100)*pow(2,b);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if( (i+j) %2 == 0){
                    cout << "#";
                } else{
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    int X,Y,Z;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
    return 0;
}


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

using lint = long long;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N;
    cin >> N;

    if(N == 1) {
        cout << "Hello World" << endl;
        exit(0);
    }

    lint A, B;
    cin >> A >> B;
    cout << A + B << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

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

void solve() 
{
    int n;cin>>n;int f=0;
    REP(i,2000000){
        f=(f*10+7)%n;
        if(!f){
            cout<<i+1<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

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

Measured memory_bytes: 3612
//D - Not Divisible


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define rep(i, n) for (int i = 0; i < (n); ++i)


using namespace std;

const int M = 1000005;

int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vi A(n);
	rep(i,n) cin>>A[i];
	sort(A.begin(), A.end());

	vi cnt(M);
	for(int x:A){
		if (cnt[x] != 0)
		{
			cnt[x]++;
			continue;

		}
		for (int i = x; i < M; i+=x)
		{
			cnt[i]++;
		}
	}
	int ans =0;
	for(int x :A){
		if(cnt[x] ==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7992
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main() {
	
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printYN(b - a == c - b);
	
	Please AC;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;

int		main(void)
{
	int N;
	cin >> N;
	set<string> st;
	for (int i = 0; i < N; i++)
	{
		string str;
		cin >> str;
		st.insert(str);
	}
	cout << st.size() << endl;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d)
    cout<<"Yes"<<endl;
  else if(abs(a-b)<=d && abs(c-b)<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
	cin>>n;
	if(n<10) cout<<"Yes\n";
	else{
		bool f = false;
		forni(i,10){
			if(n%i==0 && n/i<10) f = true;
		}
		(f)?cout<<"Yes\n":cout<<"No\n";
	}
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3580
// Aizu 1297: Swimming Jam
// 2017.11.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 52
typedef struct { int t, c, a; } T;   // a: arive time
T q[2][MAX+2]; int top[2], end[2];
T p[MAX+2]; int sz;

int cmp(T *a, T *b) { return a->t - b->t; }

int main()
{
	int n, i, j, k, t, a, ans;

    while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++ ) scanf("%d%d", &p[i].t, &p[i].c), p[i].a = p[i].t;
		qsort(p, n, sizeof(T), cmp);
		top[0] = top[1] = end[0] = end[1] = 0;
		for (i = 0; i < n; i++)	q[0][end[0]++] = p[i];

		ans = 0;
		while (n > 0) {
			int t0, t1;
			t0 = t1 = 0x7fffffff;
			if (top[0] != end[0]) t0 = q[0][top[0]].a;
			if (top[1] != end[1]) t1 = q[1][top[1]].a;
			if (t0 <= t1) j = 0;
			else j = 1;

			sz = t = 0;
			while (top[j] != end[j]) {
				k = top[j];
				a = q[j][k].a;
				if (t == 0) t = a;
				else if (t < a) break;
				if (j == 1) q[j][k].c--;
				if (q[j][k].c == 0) n--, ans = t;
				else p[sz] = q[j][k], p[sz].a = t + p[sz].t, sz++; 
				if (++k == MAX) k = 0;
				top[j] = k;
			}
			if (n == 0) break;
			qsort(p, sz, sizeof(T), cmp);

			for (i = 0; i < sz; i++) {
				q[!j][end[!j]] = p[i]; if (++end[!j] == MAX) end[!j] = 0;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

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

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> vSize;

    UnionFind(int N) : par(N), vSize(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++)
        {
            par[i] = i;
            vSize[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        vSize[ry] += vSize[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){    // データxが属する木の頂点数を得る
        int rx = root(x);
        return vSize[rx];
    }
};

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    REP(i, M)
    {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    UnionFind tree(N);
    vector<ll> ans(M + 1, 0);

    for (int i = M; i >= 0; --i)
    {
        if (i == M) 
        {
            ans[i] = N * (N - 1) / 2;
        }
        else
        {
            if (!tree.same(A[i], B[i]))
            {
                ll connected = (ll)tree.size(A[i]) * (ll)tree.size(B[i]);
                ans[i] = ans[i + 1] - connected;
                tree.unite(A[i], B[i]);
            }
            else
            {
                ans[i] = ans[i + 1];
            }
        }
    }

    for (int i = 1; i <= M; ++i) cout << ans[i] << endl;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0) cout << (b-a)/2 << endl;
    else{
        ll ans = a + ((b-a) - 1)/2;
        chmin(ans, (n+1-b) + (n - (a+(n-b+1)))/2);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3636